<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
  <channel>
    <title>small developer</title>
    <description>To be independent and sticking to your views Show your adamancy especially in hard time.</description>
    <link>http://cherryremind.javaeye.com</link>
    <language>UTF-8</language>
    <copyright>Copyright 2003-2008, JavaEye.com</copyright>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <generator>JavaEye - 做最棒的软件开发交流社区</generator>
      <item>
        <title> 变量转移 Variable Change</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/210318" style="color:red;">http://cherryremind.javaeye.com/blog/210318</a>&nbsp;
          发表时间: 2008年07月01日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          看了一个片子《决胜21点》， 里面有段， 教授出了一题，“3扇门， 一扇门是对的， 另外的是错的， 你怎么选择”， Ben说，“我选第一扇门”， “OK, 那我告诉你第三扇门是错的， 现在再给你一次机会， 你选哪个？”，Ben说“第二扇 ！”， 教说“Good! ...”<br /><br />听到一个词"变量转移。。"  仔细想想也对。嘿嘿<br /><br />see these answers:<br />http://answers.yahoo.com/question/index?qid=20080406131845AAhHQHE<br /><br />第二次如果继续选第一扇门， 那概率还是1/3， 所以换一下，选第二扇， 就是2/3了
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/210318#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 01 Jul 2008 22:22:01 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/210318</link>
        <guid>http://cherryremind.javaeye.com/blog/210318</guid>
      </item>
      <item>
        <title>Random</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/208397" style="color:red;">http://cherryremind.javaeye.com/blog/208397</a>&nbsp;
          发表时间: 2008年06月26日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          Java, .Net and . C, C++.<br />Ruby,  Python,  Php,  Erlang, Scala<a href="http://www.scala-lang.org" target="_blank">http://www.scala-lang.org</a>/.  <br />Js, As.
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/208397#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Thu, 26 Jun 2008 23:01:20 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/208397</link>
        <guid>http://cherryremind.javaeye.com/blog/208397</guid>
      </item>
      <item>
        <title>21天 Ruby-------- conditional</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/195700" style="color:red;">http://cherryremind.javaeye.com/blog/195700</a>&nbsp;
          发表时间: 2008年05月22日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          最近一直忙着面试... 现在终于有时间来继续学习ruby了.  :)<br /><br />ruby中的条件语句<br /><pre name="code" class="ruby">
a = 8
if a > 0
  puts "a > 0"
elsif a &lt; 0
  puts "a &lt; 0"
else
  puts "a == 0"
end

a = 0
str = if a > 0 then "a > 0"
elsif a &lt; 0 then "a &lt; 0"
else "a == 0"
end
puts str


a = 0
puts "a == 0  g" if a == 0
puts "a == 0  h" unless a != 0


a = 1
case a
  when -1
    puts "a == -1"
  when 0
    puts "a == 0"
  when 1
    puts "a == 1"
  else
    puts "unknown"
end

a = "a"
case a
  when "a"
    puts "a == -1"
  when "b"
    puts "a == 0"
  when "c"
    puts "a == 1"
  else
    puts "unknown"
end


a = 3
str = case a
  when -10..-1 then "-10 &lt; a &lt; 0"
  when 0 then "a == 0"
  when 1..10 then "1 &lt; a &lt; 10"
  else "unknown"
end
puts str

</pre><br /><br /><div class="quote_title">引用</div><div class="quote_div"><br />a > 0<br />a == 0<br />a == 0  g<br />a == 0  h<br />a == 1<br />a == -1<br />1 &lt; a &lt; 10<br /><br /></div><br />和JAVA对比,ruby:<br />1. 对一个字符的赋值后来也可以跟, 条件语句, JAVA中可能要匿名内部类来做<br />2. unless 相当于if not 效果<br />3. switch语句, JAVA中的switch只能对数字或者enum来用, 不支持字符串, 而ruby可以
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/195700#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Thu, 22 May 2008 15:50:53 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/195700</link>
        <guid>http://cherryremind.javaeye.com/blog/195700</guid>
      </item>
      <item>
        <title>21天 Ruby-------- oo</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/188920" style="color:red;">http://cherryremind.javaeye.com/blog/188920</a>&nbsp;
          发表时间: 2008年05月02日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <pre name="code" class="ruby">
class People
  def initialize(name, age)
    @name = name
    @age = age
  end
  
  def to_s
    "name = #{@name}, age = #{@age}"
  end
end

lily = People.new("Lily", 18)
puts lily

class Teacher &lt; People
  def initialize(name, age, gender)
    super(name, age)
    @gender = gender
  end
  
  def to_s
    super + ", gender = #{@gender}"
  end
end

lisa = Teacher.new("Lisa", 28, "female")
puts lisa
</pre><br />--><br />1. 继承的用法<br />2. 重写的用法
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/188920#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Fri, 02 May 2008 21:53:45 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/188920</link>
        <guid>http://cherryremind.javaeye.com/blog/188920</guid>
      </item>
      <item>
        <title> 'guice', 'warp' ,'domain driven design' </title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/188466" style="color:red;">http://cherryremind.javaeye.com/blog/188466</a>&nbsp;
          发表时间: 2008年04月30日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <strong>guice -- dependent injection<br />warp  -- dynamic finder</strong><br /><br />AbsEntity ---- 抽象类 提炼所有域对象的Generic属性和行为<br />IEntity   ---- 对象行为的Generic接口<br /><br />觉得Annotation用的舒服啊. MainModule.java替代Spring的applicationContext.xml配置文件<br /><br /><pre name="code" class="java">
import java.io.Serializable;
import java.util.Date;
import java.util.List;

import javax.persistence.EntityManager;

import com.wideplay.warp.persist.Transactional;

/**
 * &lt;p>
 * Entity interface implemented by all persistent classes.
 */
public interface IEntity&lt;T, PK extends Serializable>
{
	public void setEmp(com.google.inject.Provider&lt;EntityManager> emp);

	public String getId();

	public Date getCreatedAt();

	public void setCreatedAt(Date createAt);

	public Date getChangedAt();

	public void setChangedAt(Date changedAt);

	public List&lt;String> validate();

	public T find(PK id);

	public List&lt;T> findAll();

	@Transactional
	public T save(T object);

	@Transactional
	public void remove(PK id);

}
</pre><br /><br /><pre name="code" class="java">
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EntityManager;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import com.google.inject.Inject;
import com.wideplay.warp.persist.Transactional;

/**
 * 
 * &lt;p>
 *  This class provides the basic properties for entities (id, createdAt, and
 *  changedAt) as well as default save, remove, find, and findAll methods.
 * 
 * &lt;p>
 *  Custom finders and custom save / remove logic can be implemented in child
 *  entity classes as necessary.
 */
@MappedSuperclass
public abstract class AbsEntity&lt;T, PK extends Serializable> implements IEntity&lt;T, PK>
{

	@Transient
	@Inject
	protected com.google.inject.Provider&lt;EntityManager> emp;

	@Transient
	private Class&lt;T> persistentClass;
	
	@Id
	@Column(length = 36, nullable = false)
	//@GeneratedValue(strategy = GenerationType.AUTO)
	@GeneratedValue(generator = "hibernate-uuid.hex")
	@org.hibernate.annotations.GenericGenerator(name = "hibernate-uuid.hex", strategy = "uuid.hex")
	protected String id;
	

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "created_at", nullable = false)
	protected Date createdAt = new Date();

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "changed_at", nullable = false)
	protected Date changedAt = new Date();

	/**
	 * Constructor for dependency injection.
	 * 
	 * @param persistentClass
	 *            the class type you'd like to persist.
	 */
	public AbsEntity(Class&lt;T> persistentClass)
	{
		this.persistentClass = persistentClass;
	}

	public void setEmp(com.google.inject.Provider&lt;EntityManager> emp) {
		this.emp = emp;
	}

	public String getId() 
	{
		return id;
	}

	public Date getCreatedAt()
	{
		return createdAt;
	}

	public void setCreatedAt(Date createdAt)
	{
		this.createdAt = createdAt;
	}

	public Date getChangedAt() 
	{
		return changedAt;
	}

	public void setChangedAt(Date changedAt) 
	{
		this.changedAt = changedAt;
	}

	public List&lt;String> validate() 
	{
		// create our list for errors
		List&lt;String> errors = new ArrayList&lt;String>();

		// Validate the model fields.
		if (this.id == null || this.id.length() == 0) 
		{
			errors.add("Identifier is null or empty.");
		}
		if (this.createdAt == null)
		{
			errors.add("Created at date is null.");
		}
		// if no errors occured we'll return null.
		if (errors.size() == 0)
		{
			errors = null;
		}

		// return errors that occured
		return errors;
	}

	public T find(PK id)
	{
		return emp.get().find(this.persistentClass, id);
	}

	@SuppressWarnings("unchecked")
	public List&lt;T> findAll()
	{
		return emp.get().createQuery(
				"FROM " + this.persistentClass.getSimpleName()).getResultList();
	}


	@Transactional
	public T save(T object) 
	{
		return emp.get().merge(object);
	}


	@Transactional
	public void remove(PK id) 
	{
		EntityManager em = emp.get();
		em.remove(em.find(this.persistentClass, id));
	}

	@SuppressWarnings("unchecked")
	@Override
	public boolean equals(Object o)
	{
		if (this == o)
			return true;
		if (o == null || !(o instanceof IEntity))
		{
			return false;
		}
		IEntity other = (IEntity) o;

		// if the id is missing, return false
		if (id == null)
		{
			return false;
		}

		// equivalence by id
		return id.equals(other.getId());
	}

	@Override
	public int hashCode() 
	{
		if (id != null)
		{
			return id.hashCode();
		}
		else 
		{
			return super.hashCode();
		}
	}

	@Override
	public String toString() 
	{
		// TODO Auto-generated method stub
		return "id: " + id + ", createdAt: " + createdAt.toString()
				+ ", changedAt: " + changedAt.toString();
	}
}

</pre><br /><br /><pre name="code" class="java">

import java.util.List;

import javax.persistence.Column;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.DiscriminatorType;
import javax.persistence.Entity;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import com.google.inject.name.Named;
import com.model.Role;
import com.wideplay.warp.persist.dao.Finder;

@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
@DiscriminatorColumn(name = "USER_TYPE", discriminatorType = DiscriminatorType.STRING)
@Table(name = "USER")
public abstract class BaseUser extends AbsEntity&lt;BaseUser, String> implements IEntity&lt;BaseUser, String> 
{
	 @Column(name = "EMAIL")
	 private String email;

	 @Column(name = "PASSWORD", length = 50)
	 private String password;

	 @Column(name = "FULL_NAME", length = 50)
	 private String fullName;

	 @Column(name = "ACTIVE")
	 private boolean active = true;
	  
	 @Column(name = "LOGIN_RANDOM_PASSWORD") 
	 private String loginRandomPassword;
	    
    @ManyToOne(targetEntity = Role.class)
    @JoinColumn(name = "FK_ROLE_ID")
    private Role role;
    
	/**
	 * Necessary to use the generic operation methods in AbsEntity.
	 */
	@SuppressWarnings("unchecked")
	public BaseUser()
	{
		super(BaseUser.class);
	}
	
	/** ********************************************** */
	/** Properties *********************************** */
	/** ********************************************** */

	public String getEmail() 
	{
		return email;
	}

	public void setEmail(String email) 
	{
		this.email = email;
	}

	public String getPassword()
	{
		return password;
	}

	public void setPassword(String password) 
	{
		this.password = password;
	}

	public String getFullName()
	{
		return fullName;
	}

	public void setFullName(String fullName) 
	{
		this.fullName = fullName;
	}

	public boolean isActive()
	{
		return active;
	}

	public void setActive(boolean active) 
	{
		this.active = active;
	}

	public String getLoginRandomPassword() 
	{
		return loginRandomPassword;
	}

	public void setLoginRandomPassword(String loginRandomPassword)
	{
		this.loginRandomPassword = loginRandomPassword;
	}

	public Role getRole() 
	{
		return role;
	}

	public void setRole(Role role)
	{
		this.role = role;
	}
		
	/** ********************************************** */
	/** Operators ************************************ */
	/** ********************************************** */

	// Override save, remove, find, and findAll methods as necessary.
	//
	/** ********************************************** */
	/** Custom Finders ******************************* */
	/** ********************************************** */
	@Finder(query = "FROM Role WHERE id = :roleId")
	public Role findRoleById(@Named("roleId")Long roleId) 
	{
		return null; // never called
	}
	
	@Finder(query = "From Role order by roleName")
	public List&lt;Role> findAllRoles() 
	{
		return null;
	}


}

</pre><br /><br /><pre name="code" class="java">
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

import com.model.abs.BaseUser;

@Entity()
@DiscriminatorValue("C_USER")
public class CustomUser extends BaseUser 
{
	/** ********************************************** */
	/** Custom Finders ******************************* */
	/** ********************************************** */
}
</pre><br /><br /><pre name="code" class="java">
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.google.inject.Inject;
import com.wideplay.warp.persist.PersistenceService;

public class InitializerJpa 
{
	private final Log log = LogFactory.getLog(getClass());

	@SuppressWarnings("unused")
	private final PersistenceService service;

	/**
	 * Starters the JPA persistence service.
	 * 
	 * @param service
	 *            the persistence service to start.
	 */
	@Inject
	InitializerJpa(PersistenceService service) 
	{
		this.service = service;

		service.start();
		log.info("JPA Persistence Service started...");
	}
}
</pre><br />这个Module就像applicationContext.xml的功能<br /><pre name="code" class="java">
import com.app.InitializerJpa;
import com.google.inject.AbstractModule;
import com.wideplay.warp.jpa.JpaUnit;


public class MainModule extends AbstractModule 
{
	protected void configure() 
	{
		bindConstant().annotatedWith(JpaUnit.class).to("Persist_Unit");

		// to automatically start up the persistence service
		bind(InitializerJpa.class).asEagerSingleton();
	}
}

</pre><br /><br />Persist_Unit.xml 数据库的配置<br /><pre name="code" class="xml">
&lt;?xml version="1.0" encoding="UTF-8" ?> 
&lt;persistence xmlns="http://java.sun.com/xml/ns/persistence"

	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
	http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">

	&lt;!-- A JPA Persistence Unit -->
	&lt;persistence-unit name="Persist_Unit" transaction-type="RESOURCE_LOCAL">
		&lt;provider>org.hibernate.ejb.HibernatePersistence&lt;/provider>
 
		&lt;!-- JPA entities can be registered here, but it's not necessary -->

		&lt;properties>
            &lt;property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
            &lt;property name="hibernate.connection.url" value="jdbc:mysql://localhost/ex_ddd"/>
            &lt;property name="hibernate.connection.username" value="root"/>
            &lt;property name="hibernate.connection.password" value="123"/>
            &lt;property name="hibernate.connection.pool_size" value="1"/>
            &lt;property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
			&lt;property name="hibernate.hbm2ddl.auto" value="create"/> 
        &lt;/properties>
        
	&lt;/persistence-unit>

&lt;/persistence>

</pre>
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/188466#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Wed, 30 Apr 2008 16:25:22 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/188466</link>
        <guid>http://cherryremind.javaeye.com/blog/188466</guid>
      </item>
      <item>
        <title>21 天Ruby-------- loop</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/186739" style="color:red;">http://cherryremind.javaeye.com/blog/186739</a>&nbsp;
          发表时间: 2008年04月25日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <pre name="code" class="ruby">
class ForLoop
  
  def callFor 
    for i in 1..3
      print "index = #{i}\n"
    end
  end
  
  def callWhile
    a = 1
    a *= 2 while a &lt; 10
    puts a
    
    a -= 2 until a &lt; 0
    puts a
  end
  
  def callWhile2
    a = 1
    a += 1  while a &lt; 5
    puts a
  #  print "index = #{a}\n"
  end

  def time
    3.times do
      print "Ho! "
    end
  end
  
  def upto
     1.upto(3) do |x|
      puts x
    end
  end
  
  def step
    0.step(10, 2) do |x|
      puts x
    end
  end

  def each 
    [1, 2, 3, 4, 5].each do |x|
      puts x
    end
  end
  
  def callFor2  # seems similar as each
    for n in [5, 4, 3, 2, 1]
      puts n
    end
  end
  
  def callLoop
     i = 0
     loop do
      i += 1
      puts i
      next if not i > 3
      puts "i > 3"
      redo if i >= 6 and i &lt;= 9
      puts "i &lt; 6 or i > 9"
      break if i == 10 
    end
  end
  
end

instance = ForLoop.new
instance.callFor
print "----------\n"
instance.callWhile2
print "----------\n"
instance.time
print "\n----------\n"
instance.upto
print "----------\n"
instance.step
print "----------\n"
instance.each
print "----------\n"
instance.callFor2
print "----------\n"
instance.callLoop

# output
#index = 1
#index = 2
#index = 3
#----------
#5
#----------
#Ho! Ho! Ho! 
#----------
#1
#2
#3
#----------
#0
#2
#4
#6
#8
#10
#----------
#1
#2
#3
#4
#5
#----------
#5
#4
#3
#2
#1
#----------
#1
#2
#3
#4
#i > 3
#i &lt; 6 or i > 9
#5
#i > 3
#i &lt; 6 or i > 9
#6
#i > 3
#7
#i > 3
#8
#i > 3
#9
#i > 3
#10
#i > 3
#i &lt; 6 or i > 9

</pre><br /><br />ruby loop变现形式真多
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/186739#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Fri, 25 Apr 2008 13:30:03 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/186739</link>
        <guid>http://cherryremind.javaeye.com/blog/186739</guid>
      </item>
      <item>
        <title>21天 Ruby-------- symbol</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/186671" style="color:red;">http://cherryremind.javaeye.com/blog/186671</a>&nbsp;
          发表时间: 2008年04月25日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          Test1.rb<br /><br /><pre name="code" class="ruby">
print "1: "
puts "name".object_id
print "1: "
puts "name".object_id
print "1: "
puts "name".object_id

print "2: "
puts :name.object_id
print "2: "
puts :name.object_id
print "2: "
puts :name.object_id

print "3: "
puts 123456.object_id
print "3: "
puts 123456.object_id
print "3: "
puts 123456.object_id

# output
#1: 21719110
#1: 21719080
#1: 21719050 
#  "name".object --> 对象的Id
#2: 34258
#2: 34258
#2: 34258
#  :name.object_id  -->  对象的值的Id
#3: 246913
#3: 246913
#3: 246913
</pre><br />==><br />1.对象的相同的字符串，他们的对象不同， 但是 属性的值的Id相同<br />像java里面的Long与long区别 <br />3.数字型的 对象Id相等<br /><br />Test2.rb<pre name="code" class="ruby">
class A
  attr_accessor :name
end

a = A.new
print "a.name = "
puts a.name

a.name = "Lily"
print "a.name = "
puts a.name

class B
  def name
    @name
  end
  
  def name=(name)
    @name = name
  end
end

b = B.new
print "b.name = "
puts b.name

b.name = "Lily"
print "b.name = "
puts b.name

# output
#a.name = nil
#a.name = Lily
#b.name = nil
#b.name = Lily
</pre><br />==><br />1. 对象属性没有值的时候，为nil， 感觉是"Null Object"<br />2. ttr_accessor :name 的效果 当然于class B里面的<br /><br />Test3.rb<br /><pre name="code" class="ruby">
class Symbol
  def to_proc
    proc {|obj, *args| obj.send(self, *args)}
  end
end

words = %w(abc bcd cde def efg)
list = words.map(&:capitalize)
print "1: "
puts list.inspect

list2 = words.map {|w| w.send(:capitalize)}
print "2: "
puts list2.inspect
</pre><br />==><br />1. ruby中的神奇函数inspect，<br />2. capitalize顾名思义<br />#TODO
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/186671#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Fri, 25 Apr 2008 11:16:46 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/186671</link>
        <guid>http://cherryremind.javaeye.com/blog/186671</guid>
      </item>
      <item>
        <title>Design Pattern --------------------- Iterator </title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/180500" style="color:red;">http://cherryremind.javaeye.com/blog/180500</a>&nbsp;
          发表时间: 2008年04月08日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <strong>好文借鉴</strong><br /><div class="quote_title">引用</div><div class="quote_div">对容器中元素的访问涉及到3个方面。<br />1．容器的类型<br />2．检索容器内元素的方法<br />3．对元素的操作<br />比如说我们有一个表示书店的book_store类。里面保存了各种各样的book类的实例。<br />book类有name和type两种属性。表示书的名字和类别。<br />因此book_store类内部会用一个容器来保存book的实例。比如list。<br />class book<br />{<br />public:<br />string name;<br />string type;<br />};<br /><br />class book_store<br />{<br />private:<br />list&lt;book> m_books;<br />};<br /><br />我们现在有这样一个简单的应用，那就是输出所有的书名到屏幕。<br />那么我们来看一下在引入Iterator模式前有那几种实现方法，各有什么缺点。<br />1．给book_store类增加一个print_book_name的函数。来实现这个功能。<br />这样做的缺点有两个：<br />（1）．将输入输出逻辑和业务对象绑定在一起，导致了今后系统难以变更。<br />（2）．输出逻辑和内部实现绑定。<br />比如现在要把输出到屏幕改成输出到log文件的话，那么就需要修改print_book_name了。<br />2．给book_store类增加一个get_list函数。然后写一个print_book类来负责打印书名的列表。这是一个初学者常用的方式。表面上看来似乎两个类各担其责，一个表示业务对象一个负责打印。<br />如果需要打印到log文件的话，只要新增加一个log_book类，book_store和print_book都不受影响。解决了上面的这个问题。<br />这样做的缺点是：<br />（1）．把book_store类的内部实现给暴露出来了，违反了封装的原则。<br />如果现在把内部容器类型从list换成了vector的话，就要修改输出逻辑了。也就是说，要同时改写print_book类和log_book类。<br />3．增加一个list和vector类共同的基类/接口，比如I_container。然后给book_store类增加一个get_books函数，返回I_container。<br />这在一定程度上解决了上面的问题。但是并不彻底。应为还是暴露了内部的实现，只不过从list上升到了I_container。<br />· 如果现在系统发生了变化，book_store不再在本地保存books了，而是需要通过网络取得的话，print_book和log_book就无法对应了。<br />· 另一个限制是，我需要一个新的机能，那就是打印所有type为”烹饪书”的机能的话，就需要一个print_cook_book类了，而这里边的格式化代码和输出代码和print_book是相同的。重复代码是维护的噩梦。<br /><br />接下来我们看一下Iterator模式如何解决以上的这些问题。<br />首先，我们引入一个I_iterator的Interface。<br />然后创建一个I_iterator的实现类all_book_iterator。这个类可以迭代book_store中的所有book。<br />接下来创建一个print_book类，从I_iterator中取得每一个book，然后打印到屏幕。<br /><br />下面我们看一下如何对应上面的这些需求变更。<br />1．要求输出到log文件<br />追加一个log_book类，其他都类都不需要改变。<br />2．将内部容器从list变成vector。<br />修改iterator中的相关代码。Iterator的使用者不会受到影响。<br />3．从网络取得数据。<br />修改iterator中的相关代码。Iterator的使用者不会受到影响。<br />4．按照type检索<br />在iterator中添加一个type的属性，或者是构造一个新的type_search_iterator。<br />在iterator中把不符合检索条件的book过滤掉。<br />5．按照某一特定顺序输出book名到屏幕，或是log文件。<br />实现一个按该顺序输出的iterator。<br />6．以同样的方式打印cd_store。<br />实现对应于cd_store的iterator。<br /><br />可见，iterator模式在各种iterator中封装了检索元素的方法。<br />将容器和对容器中元素的操作完全隔开。<br />大大增加了代码的可重用性。 </div>
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/180500#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 08 Apr 2008 15:57:35 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/180500</link>
        <guid>http://cherryremind.javaeye.com/blog/180500</guid>
      </item>
      <item>
        <title>Design Pattern --------------Flyweight</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/180496" style="color:red;">http://cherryremind.javaeye.com/blog/180496</a>&nbsp;
          发表时间: 2008年04月08日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <strong>好文借鉴</strong><br /><div class="quote_title">引用</div><div class="quote_div"> <br /><br />1. Flyweight是减少内存的使用量的一种模式，间接的可能会提高性能。两者没有必然联系。<br /><br />2. Flyweight和Object pool完全不同。FlyWeight内部用到的共享机制在实现上和object cache有点像，但是有本质上的区别。不要把两者混为一谈。请仔细读一下GoF的原著。<br /><br />3. Flyweight未必会减少实例的创建次数。反而可能会增加实例的创建次数。（尤其对于非JAVA语言）<br /><br />4. Flyweight内部的共享机制和object pool的区别。<br />4.1 原理不同<br />object pool的原理是复用（一个对象被反复使用，但同时只有一个“人”在使用），flyweight的原理是共享(同时被多个“人”使用)。<br />object pool有一个很重要的特点，那就是pool中的对象是同质的。也就是说，对于使用者来说，可以用pool中的任何一个object。就好像当我们需要 connection时可以从connection pool中任意的拿一个出来使用，而Flyweight的每一个实例的内部属性都不同，完全是异质的。flyweight使用时，是去 FlyweightFactory中找一个特定的对象出来（如果没有的话，就创建一个）。flyweight的出发点是共享。而object pool中的对象是不能共享的。<br />4.2 运用的场合不同<br />object pool对应的场景是对象被频繁创建，使用，然后销毁这样一种情况。也就是说，每个对象的生命期都很短。同一时刻内，系统中存在的对象数也比较小。而Flyweight对应的情况是在同一时刻内，系统中存在大量对象。<br /><br />5. Flyweight内部共享机制和object cache的区别。<br />5.1 原理不同<br />cache的原理是程序的局部访问性原理。对一小部分经常使用到的对象/数据提供一个高速的存储。而大部分数据放在一个低速的存储中。因此有cache算法和命中率的问题。flyweight的共享机制中，并没有高速和低速的问题。也不存在命中率的问题。可能会有一个查找算法的问题。<br />5.2 运用场合的不同。<br />cache运用在一小部分对象会被经常访问到的情况。比如说论坛中置顶的帖子。<br />flyweight用在同时使用到大量对象的情况。比如在屏幕上绘制一张有100万个电子元器件的电路图。这个时候每个对象都被用到一次，且只被用到一次。<br /><br />6 在这里再提一下Buffer这个概念。<br />Buffer的原理是减小访问的波动性。在软件开发上用的比较少。这里就不说了。<br /></div>
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/180496#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 08 Apr 2008 15:48:02 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/180496</link>
        <guid>http://cherryremind.javaeye.com/blog/180496</guid>
      </item>
      <item>
        <title>Date with timezone convert</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/159131" style="color:red;">http://cherryremind.javaeye.com/blog/159131</a>&nbsp;
          发表时间: 2008年01月24日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          中国在行政上对全国各地都定义一个统一的时区，也就是我们通常所说的"北京时间"。而美国大陆本土有 5 个主要时区（Arizona州单独一个时区），再加夏威夷时区和阿拉斯加时区。国土面积不大的澳大利亚竟有 5 个时区。但是如果我们所开发的应用是要考虑支持多个时区共享使用时，我们需要对 Java 的时区要有一个了解。例如，如何将一个时区下定义的时间转换到另一个时区来显示，等等问题。<br /><br />全球时区参考<a href="http://greenwichmeantime.com/time-zone/" target="_blank">http://greenwichmeantime.com/time-zone/</a><br /><br />最近客户要求在对于取日期要根据 申请者 所在时区的时间来计算。<br />例如 一个来自美国西部CA州的人， 处在美国东部IL州， Server不管在哪里。<br />CurrentDate（当前时间） 是应该取 以Server时间为准，换算成申请者来自与州的时间。<br />因为当前时间可能相差一天。<br /><pre name="code" class="java">
  //  现有代码，好多取当前时间直接  new Date() 只是取当前Server的时间
     new Date();
</pre><br /><br />Java的Date型没有对 timezone 支持,而现在代码日期都是Date， DB也是存Date型<br />我们都知道使用 calendarInstance.getTime() 来转换成 Date<br /><pre name="code" class="java">
       //  使用指定时区 PST(太平洋时区) 和默认语言环境获得一个日历。
	 Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("PST"));
       //    使用默认时区和语言环境获得一个日历。
        Calendar calendar2 = Calendar.getInstance();
		
		System.out.println(calendar.getTime() + " " + calendar.getTimeInMillis());
		System.out.println(calendar2.getTime() + " " + calendar2.getTimeInMillis());
</pre><br />惊讶的发现， 直接这样转换， 打出的来结果是一样的.<br /><br />后来自己的代码写这样， 相信大家在写代码的时候也遇到过类型的问题，如果有更好的方法， 请不吝赐教<br /><pre name="code" class="java">

    private static Map&lt;String, String> US_TimeZoneMap = null;

    /**
     *  Get right timezone date by calendar
     * 
     * @param stateCode  state name
     * @return Date timezoneDate
     */
    @SuppressWarnings("deprecation")
    public static Date getTimezoneDate(String stateCode)
    {    
        Calendar calendar = Calendar.getInstance(getTimezone(stateCode));
        Date date = new Date(calendar.get(Calendar.YEAR),
                              calendar.get(Calendar.MONTH),
                               calendar.get(Calendar.DAY_OF_MONTH));
        return date;
    }
   
    /**
     *  Get timezone type by state name
     * 
     * @param stateCode
     * @return TimeZone
     */
    public static TimeZone getTimezone(String stateCode)
    {
        return TimeZone.getTimeZone(initializeTimezoneMap().get(stateCode));
    }
   
    /**
     *  Initialize a map store timezone info
     * 
     * @return Map  timezone Map
     */
    public static Map&lt;String, String> initializeTimezoneMap()
    {
        if (US_TimeZoneMap == null)
        {
            US_TimeZoneMap = new HashMap&lt;String, String>();
            US_TimeZoneMap.put("CA", "PST");
            US_TimeZoneMap.put("CO", "MST");
            // ...
            US_TimeZoneMap.put("IL", "CST");
            US_TimeZoneMap.put("GA", "EST");
        }

        return US_TimeZoneMap;
    }
</pre><br /><br />这篇文章介绍java timezone， 很详细 <a href="http://www.ibm.com/developerworks/cn/java/l-datetime/part2/index.html" target="_blank">http://www.ibm.com/developerworks/cn/java/l-datetime/part2/index.html</a><br /><br /><br />还有个开源的Java date and time classes -----<strong>Joda</strong>. <a href="http://joda-time.sourceforge.net/index.html" target="_blank">http://joda-time.sourceforge.net/index.html</a><br /><br /><div class="quote_title">引用</div><div class="quote_div">Joda-Time has been created to radically change date and time handling in Java. The JDK classes Date and Calendar are very badly designed, have had numerous bugs and have odd performance effects. ...</div><br /><br /><pre name="code" class="java">
 	    // get current moment in default time zone
	    DateTime dt = new DateTime();
	    // translate to London local time
	    DateTime dt2 = dt.withZone(DateTimeZone.forID("America/Los_Angeles"));

// This is similar in concept to the default time zone of the java.util.TimeZone class.
DateTimeZone defaultZone = DateTimeZone.getDefault();
DateTimeZone.setDefault(myZone);
</pre><br /><br />试用了下，感觉还不错，支持TIMEZONE挺好的。 以后可以考虑使用。<br />有的国外项目直接用joda的 Datetime取代SUN 的Date
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/159131#comments" style="color:red;">已有 <strong>1</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Thu, 24 Jan 2008 16:24:15 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/159131</link>
        <guid>http://cherryremind.javaeye.com/blog/159131</guid>
      </item>
      <item>
        <title>&lt;重构&gt;笔记</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/155600" style="color:red;">http://cherryremind.javaeye.com/blog/155600</a>&nbsp;
          发表时间: 2008年01月14日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          重构：<br />    在不改变的前提下，提高代码的可理解性，降低其修改成本<br /><br /><br /><br />The rule of three<br />添加功能时一并重构<br />修补错误时一并重构<br />复审代码时一并重构<br /><br />composing method<br /><br />a. Extract method. divide a method into two or more method.<br />提炼方法， 把能分开，重用的部分单独做一个方法。<br /><br />b. Inline method. conclude two or method into one method.<br />和Extract method相反， 概括多个方法成一个， 简化代码.<br /><br />c. Inline temp. remove temp variable as we can.<br /><br /><br />d. Replace temp with query. change temp variable 's operation into a method that can be recall some other place<br /><br /><br />e. Introduce explaining variable. change series of operation into some explaining variable, use clear name<br /><br /><br />f. Split temporary variable. won't reuse temp variable for many set value operation, it make other confused<br /><br /><br />g. Remove assignments to parameters. <br />create a temp variable instead of object, java only use pass by value (参数不要用来赋值, 使用final, 避免对参数赋值)<br /><br /><br />h. Replace method with method object.<br /> create method object( TestObject _testObject), use 'Extract method', use '_testObject.testMethod()'(method object)<br /><br /><br />i. Substitute algorithm. improve algorithm<br /><br />        <br /><br /><br />Moving features between objects<br /><br /><br />a. Move method<br /><br />b. Move field<br /><br />c. Extract class.<br /><br />d. Inline class.<br /><br />e. Hide delegate.  (对method进行加一层封装，使Client不能直接访问method. 简单委托关系)<br /><br />f. Remove middle man. 和Hide delegate相反， 合理的隐藏程序基于实际系统的变化<br /><br />g.Introduce foreign method.  create new method, set server class entity as argument<br />                         ex:           Date date = new Date(pro.getYear(), pro.getMonth(), pro.getDay()+1)<br />                          ---->         Date date = nextDay(pro);<br />                                           staitc Date nextDay(Date pro)<br />                                            {<br />                                                    return new  Date()<br />                                            }
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/155600#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Mon, 14 Jan 2008 11:23:23 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/155600</link>
        <guid>http://cherryremind.javaeye.com/blog/155600</guid>
      </item>
      <item>
        <title>Good collection of Linux Command</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/150341" style="color:red;">http://cherryremind.javaeye.com/blog/150341</a>&nbsp;
          发表时间: 2007年12月23日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>ITPUB上的， 总结的很全。 </p><p>&nbsp;</p><p>linux目录架构 </p>
/ &nbsp;  &nbsp;  &nbsp; 根目录 <br />
/bin &nbsp;  &nbsp;  &nbsp;  &nbsp; 常用的命令 &nbsp; binary &nbsp; file &nbsp; 的目錄 <br />
/boot &nbsp;  &nbsp;  &nbsp; 存放系统启动时必须读取的档案，包括核心 &nbsp; (kernel) &nbsp; 在内 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /boot/grub/menu.lst &nbsp;  &nbsp;  &nbsp; GRUB设置 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /boot/vmlinuz &nbsp;  &nbsp;  &nbsp; 内核 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /boot/initrd &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 核心解壓縮所需 &nbsp; RAM &nbsp; Disk <br />
/dev &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统周边设备 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
/etc &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统相关设定文件 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/DIR_COLORS &nbsp;  &nbsp;  &nbsp; 设定颜色 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/HOSTNAME &nbsp;  &nbsp;  &nbsp; 设定用户的节点名 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/NETWORKING &nbsp;  &nbsp;  &nbsp; 只有YES标明网络存在 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/host.conf &nbsp; 文件说明用户的系统如何查询节点名 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/hosts &nbsp; 设定用户自已的IP与名字的对应表 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/hosts.allow &nbsp; 设置允许使用inetd的机器使用 &nbsp;  <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/hosts.deny &nbsp; 设置不允许使用inetd的机器使用 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/hosts.equiv &nbsp; 设置远端机不用密码 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/inetd.conf &nbsp; 设定系统网络守护进程inetd的配置 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/gateways &nbsp; 设定路由器 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/protocols &nbsp; 设定系统支持的协议 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/named.boot &nbsp; 设定本机为名字服务器的配置文件 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/sysconfig/network-scripts/ifcfg-eth0 &nbsp;  &nbsp;  &nbsp; 设置IP <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/resolv.conf &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置DNS &nbsp;  &nbsp;  <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/X11 &nbsp;  &nbsp; X &nbsp; Window的配置文件,xorg.conf &nbsp; 或 &nbsp; XF86Config &nbsp; 這兩個 &nbsp; X &nbsp; Server &nbsp; 的設定檔 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/fstab &nbsp;  &nbsp;  &nbsp;  &nbsp; 记录开机要mount的文件系统 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/inittab &nbsp; 设定系统启动时init进程将把系统设置成什么样的runlevel <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/issue &nbsp; 记录用户登录前显示的信息 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/group &nbsp; 设定用户的组名与相关信息 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/passwd &nbsp; 帐号信息 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/shadow &nbsp; 密码信息 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/sudoers &nbsp; 可以sudo命令的配置文件 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/securetty &nbsp; 设定哪些终端可以让root登录 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/login.defs &nbsp; 所有用户登录时的缺省配置 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/exports &nbsp; 设定NFS系统用的 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/init.d/ &nbsp;  &nbsp;  &nbsp; 所有服務的預設啟動 &nbsp; script &nbsp; 都是放在這裡的，例如要啟動或者關閉 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/xinetd.d/ &nbsp;  &nbsp; 這就是所謂的 &nbsp; super &nbsp; daemon &nbsp; 管理的各項服務的設定檔目錄 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/modprobe.conf &nbsp;  &nbsp;  &nbsp; 内核模块额外参数设定 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/syslog.conf &nbsp;  &nbsp;  &nbsp; 日志设置文件 <br />
/home &nbsp;  &nbsp;  &nbsp; 使用者家目录 <br />
/lib &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统会使用到的函数库 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /lib/modules &nbsp;  &nbsp;  &nbsp; kernel &nbsp; 的相关模块 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /var/lib/rpm &nbsp;  &nbsp;  &nbsp; rpm套件安装处 &nbsp;  <br />
/lost+found &nbsp;  &nbsp;  &nbsp;  &nbsp; 系統不正常產生錯誤時，會將一些遺失的片段放置於此目錄下 <br />
/mnt &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 外设的挂载点 <br />
/media &nbsp;  &nbsp;  &nbsp; 与/mnt类似 <br />
/opt &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 主机额外安装的软件 <br />
/proc &nbsp;  &nbsp;  &nbsp;  &nbsp; 虚拟目录，是内存的映射 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /proc/version &nbsp;  &nbsp;  &nbsp; 内核版本 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /proc/sys/kernel &nbsp;  &nbsp;  &nbsp; 系统内核功能 <br />
/root &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统管理员的家目录 <br />
/sbin &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统管理员才能执行的指令 <br />
/srv &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 一些服務啟動之後，這些服務所需要取用的資料目錄 <br />
/tmp &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 一般使用者或者是正在執行的程序暫時放置檔案的地方 <br />
/usr &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 最大的目录，存许应用程序和文件 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/X11R6： &nbsp;  &nbsp;  &nbsp; X-Window目录 &nbsp;  <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/src： &nbsp;  &nbsp;  &nbsp;  &nbsp; Linux源代码 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/include：系统头文件 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/openwin &nbsp; 存放SUN的OpenWin &nbsp;  <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/man &nbsp; 在线使用手册 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/bin &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 使用者可執行的 &nbsp; binary &nbsp; file &nbsp; 的目錄 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/local/bin &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 使用者可執行的 &nbsp; binary &nbsp; file &nbsp; 的目錄 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/lib &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统会使用到的函数库 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/local/lib &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统会使用到的函数库 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/sbin &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统管理员才能执行的指令 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /usr/local/sbin &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统管理员才能执行的指令 <br />
/var &nbsp;  &nbsp;  &nbsp; 日志文件 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /var/log/secure &nbsp;  &nbsp;  &nbsp;  &nbsp; 記錄登入系統存取資料的檔案，例如 &nbsp; pop3, &nbsp; ssh, &nbsp; telnet, &nbsp; ftp &nbsp; 等都會記錄在此檔案中 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /var/log/wtmp &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 記錄登入者的訊息資料, &nbsp; last <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /var/log/messages &nbsp;  &nbsp; 幾乎系統發生的錯誤訊息 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /var/log/boot.log &nbsp;  &nbsp; 記錄開機或者是一些服務啟動的時候，所顯示的啟動或關閉訊息 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /var/log/maillog &nbsp;  &nbsp;  &nbsp; 紀錄郵件存取或往來( &nbsp; sendmail &nbsp; 與 &nbsp; pop3 &nbsp; )的使用者記錄 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /var/log/cron &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 記錄 &nbsp; crontab &nbsp; 這個例行性服務的內容 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; /var/log/httpd, &nbsp; /var/log/news, &nbsp; /var/log/mysqld.log, &nbsp; /var/log/samba, &nbsp; /var/log/procmail.log： <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp; 分別是幾個不同的網路服務的記錄檔 <br />
<br />
<h3>一些常用的基本命令: </h3>
uname &nbsp; -a &nbsp;  &nbsp;  &nbsp;  &nbsp; 查看内核版本 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
ls &nbsp; -al &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示所有文件的属性 <br />
pwd &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示当前路径 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
cd &nbsp; - &nbsp;  &nbsp;  &nbsp;  &nbsp; 返回上一次目录 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; cd &nbsp; ~ &nbsp;  &nbsp;  &nbsp;  &nbsp; 返回主目录 <br />
date &nbsp; s &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置时间、日期 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
cal &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示日历 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; cal &nbsp; 2006 <br />
bc &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 计算器具 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
man &nbsp;  &nbsp; &amp; &nbsp; info &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 帮助手册 <br />
locale &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示当前字体 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; locale &nbsp; -a &nbsp;  &nbsp;  &nbsp;  &nbsp; 所有可用字体 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /etc/sysconfig/i18n设置文件 <br />
LANG=en &nbsp;  &nbsp;  &nbsp;  &nbsp; 使用英文字体 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
sync &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 将数据同步写入硬盘 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
shutdonw &nbsp; -h &nbsp; now &nbsp; &amp; &nbsp; half &nbsp; &amp; &nbsp; poweroff &nbsp;  &nbsp; 关机 <br />
reboot &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 重启 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
startx &nbsp;  &nbsp; &amp; &nbsp;  &nbsp; init &nbsp; 5 &nbsp;  &nbsp;  &nbsp; 进入图形介面 <br />
/work &nbsp;  &nbsp; &amp; &nbsp; ?work &nbsp;  &nbsp;  &nbsp;  &nbsp; 向上、下查找文档内容 <br />
chgrp &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 改变档案群组 &nbsp;  &nbsp; chgrp &nbsp; testing &nbsp; install.log &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
chown &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 改变所属人 &nbsp;  &nbsp;  &nbsp; chown &nbsp; root:root &nbsp; install.log <br />
chmod &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 改变属性 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; chmod &nbsp; 777 &nbsp; install.log &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; read=4 &nbsp;  &nbsp; write=2 &nbsp;  &nbsp; execute=1 <br />
cp &nbsp;  &nbsp;  &nbsp; 复制 &nbsp;  &nbsp;  &nbsp; cp &nbsp; filename <br />
rm &nbsp;  &nbsp;  &nbsp; 删除文件 &nbsp;  &nbsp; rm &nbsp; -rf &nbsp; filename &nbsp;  &nbsp;  &nbsp; 强制删除文件 <br />
rmdir &nbsp;  &nbsp;  &nbsp; 删除文件夹 <br />
mv &nbsp;  &nbsp; 移动 &nbsp;  &nbsp;  &nbsp;  &nbsp; mv &nbsp; 123.txt &nbsp; 222.txt &nbsp;  &nbsp; 重命名 <br />
mkdir &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 创建文件夹 <br />
touch &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 创建文件 &nbsp;  &nbsp; 更新当前时间 <br />
cat &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 由第一行开始显示 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; cat &nbsp;  &amp;brvbarmore &nbsp;  &nbsp; 分页 <br />
nl &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 在内容前加行号 <br />
more &nbsp;  &nbsp; &amp; &nbsp;  &nbsp; less &nbsp;  &nbsp;  &nbsp; 一面一面翻动 <br />
head &nbsp; -n &nbsp; filename &nbsp;  &nbsp;  &nbsp; 显示第N行内容 <br />
tail &nbsp; -n &nbsp; filename &nbsp;  &nbsp; 显示后N行内容 <br />
od &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示非纯文档 <br />
df &nbsp; -h &nbsp; 显示分区空间 <br />
du &nbsp;  &nbsp; 显示目录或文件的大小 <br />
fdisk &nbsp;  &nbsp;  &nbsp; 分区设置 &nbsp;  &nbsp;  &nbsp;  &nbsp; fdisk &nbsp; -l &nbsp; /dev/hda &nbsp;  &nbsp; 显示硬盘分区状态 <br />
mkfs &nbsp;  &nbsp;  &nbsp;  &nbsp; 建立各种文件系统 &nbsp;  &nbsp; mkfs &nbsp; -t &nbsp; ext3 &nbsp;  &nbsp; /dev/ram15 &nbsp;  &nbsp;  &nbsp;  <br />
fsck &nbsp;  &nbsp;  &nbsp;  &nbsp; 检查和修复LINUX档案 <br />
ln &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 硬链接 &nbsp;  &nbsp;  &nbsp; ln &nbsp; -s &nbsp;  &nbsp; 软件链接 <br />
whereis &nbsp;  &nbsp;  &nbsp; 查找命令 <br />
locate &nbsp;  &nbsp;  &nbsp;  &nbsp; 查找 <br />
find &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 查找 &nbsp;  &nbsp;  &nbsp; find &nbsp; / &nbsp; -name &nbsp;  &quot;***.*** &quot; <br />
which &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 查看工具 <br />
whoami &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示当前用户 <br />
gcc &nbsp; -v &nbsp;  &nbsp;  &nbsp;  &nbsp; 查看GCC版本 <br />
chattr &nbsp; +i &nbsp; filename &nbsp;  &nbsp; 禁止删除 &nbsp;  &nbsp;  &nbsp; chattr &nbsp; -i &nbsp; filename &nbsp;  &nbsp; 取消禁止 <br />
lsattr &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示隐藏档属性 <br />
updatedb &nbsp;  &nbsp; 更新资料库 <br />
mke2fs &nbsp;  &nbsp;  &nbsp;  &nbsp; 格式化 &nbsp;  &nbsp;  &nbsp; mkfs &nbsp; -t &nbsp; ext3 &nbsp;  <br />
dd &nbsp; if=/etc/passwd &nbsp; of=/tmp/passwd.bak &nbsp;  &nbsp;  &nbsp;  &nbsp; 备份 <br />
mount &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 列出系统所有的分区 <br />
mount &nbsp; -t &nbsp; iso9660 &nbsp; /dev/cdrom &nbsp; /mnt/cdrom &nbsp;  &nbsp;  &nbsp; 挂载光盘 <br />
mount &nbsp; -t &nbsp; vfat &nbsp; /dev/fd0 &nbsp; /mnt/floppy &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 挂载软盘 <br />
mount &nbsp; -t &nbsp; vfat &nbsp; -o &nbsp; iocharset=utf8,umask=000 &nbsp; /dev/hda2 &nbsp; /mnt/hda2 &nbsp;  &nbsp;  &nbsp; 挂载fat32分区 <br />
mount &nbsp; -t &nbsp; ntfs &nbsp; -o &nbsp; nls=utf8,umask=000 &nbsp; /dev/hda3 &nbsp; /mnt/hda3 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 挂载ntfs分区 <br />
Linux-NTFS &nbsp; Project: &nbsp; http://linux-ntfs.sourceforge.net/ <br />
umount &nbsp; /mnt/hda3 &nbsp;  &nbsp; 缷载 <br />
ifconfig &nbsp;  &nbsp;  &nbsp; 显示或设置网络设备 <br />
service &nbsp; network &nbsp; restart &nbsp;  &nbsp;  &nbsp; 重启网卡 &nbsp;  &nbsp;  <br />
ifdown &nbsp; eth0 &nbsp;  &nbsp; 关闭网卡 <br />
ifup &nbsp; eth0 &nbsp;  &nbsp;  &nbsp;  &nbsp; 开启网卡 <br />
clear &nbsp;  &nbsp;  &nbsp;  &nbsp; 清屏 <br />
history &nbsp;  &nbsp;  &nbsp;  &nbsp; 历史记录 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; !55 &nbsp;  &nbsp; 执行第55个指令 <br />
stty &nbsp;  &nbsp;  &nbsp; 设置终端 &nbsp;  &nbsp;  &nbsp;  &nbsp; stty &nbsp; -a <br />
fdisk &nbsp; /mbr &nbsp;  &nbsp;  &nbsp; 删除GRUB <br />
at &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 僅進行一次的工作排程 <br />
crontab &nbsp;  &nbsp;  &nbsp; 循環執行的例行性命令 &nbsp;  &nbsp;  &nbsp;  &nbsp; [e]编辑,[l]显示,[r]删除任务 <br />
&amp; &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 后台运行程序 &nbsp;  &nbsp;  &nbsp;  &nbsp; tar &nbsp; -zxvf &nbsp; 123.tar.gz &nbsp; &amp; &nbsp; ---------&gt; 后台运行 <br />
jobs &nbsp;  &nbsp;  &nbsp;  &nbsp; 观看后台暂停的程序 &nbsp;  &nbsp;  &nbsp; jobs &nbsp; -l <br />
fg &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 将后台程序调到前台 &nbsp;  &nbsp;  &nbsp; fg &nbsp; n &nbsp; ------&gt; n是数字,可以指定进行那个程序 <br />
bg &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 让工作在后台运行 <br />
kill &nbsp;  &nbsp;  &nbsp;  &nbsp; 结束进程 &nbsp;  &nbsp;  &nbsp;  &nbsp; kill &nbsp; -9 &nbsp; PID &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; [9]强制结束,[15]正常结束,[l]列出可用的kill信号 <br />
ps &nbsp; aux &nbsp;  &nbsp; 查看后台程序 &nbsp;  &nbsp;  &nbsp;  <br />
top &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 查看后台程序 &nbsp;  &nbsp;  &nbsp; top &nbsp; -d &nbsp; 2 &nbsp;  &nbsp;  &nbsp;  &nbsp; 每两秒更新一次 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; top &nbsp; -d &nbsp; 2 &nbsp; -p10604 &nbsp;  &nbsp;  &nbsp; 观看某个PID <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; top &nbsp; -b &nbsp; -n &nbsp; 2 &nbsp; &gt; &nbsp; /tmp/top.txt &nbsp; -----&gt; 將 &nbsp; top &nbsp; 的資訊進行 &nbsp; 2 &nbsp; 次，然後將結果輸出到 &nbsp; /tmp/top.txt &nbsp; &nbsp; &nbsp; &nbsp; <br />
pstree &nbsp;  &nbsp;  &nbsp; 以树状图显示程序 &nbsp;  &nbsp;  &nbsp;  &nbsp; [A]以 &nbsp; ASCII &nbsp; 來連接, &nbsp; [u]列出PID, &nbsp; [p]列出帐号 <br />
killall &nbsp;  &nbsp;  &nbsp; 要刪除某個服務 &nbsp;  &nbsp;  &nbsp;  &nbsp; killall &nbsp; -9 &nbsp; httpd <br />
free &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示内存状态 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; free &nbsp; -m &nbsp;  &nbsp; --------&gt; 以M为单位显示 <br />
uptime &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示目前系统开机时间 <br />
netstat &nbsp;  &nbsp;  &nbsp; 显示网络状态 &nbsp;  &nbsp;  &nbsp;  &nbsp; netstat &nbsp; -tulnp------&gt; 找出目前系統上已在監聽的網路連線及其 &nbsp; PID <br />
dmesg &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示开机信息 &nbsp;  &nbsp;  &nbsp;  &nbsp; demsg &nbsp;  &brvbar; &nbsp; more <br />
nice &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 设置优先权 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nice &nbsp; -n &nbsp; -5 &nbsp; vi &nbsp; &amp; &nbsp; -----&gt; 用 &nbsp; root &nbsp; 給一個 &nbsp; nice &nbsp; 植為 &nbsp; -5 &nbsp; ，用於執行 &nbsp; vi &nbsp; <br />
renice &nbsp;  &nbsp;  &nbsp;  &nbsp; 调整已存在优先权 <br />
runlevel &nbsp;  &nbsp; 显示目前的runlevel <br />
depmod &nbsp;  &nbsp;  &nbsp;  &nbsp; 分析可载入模块的相依性 <br />
lsmod &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示已载入系统的模块 <br />
modinfo &nbsp;  &nbsp;  &nbsp; 显示kernel模块的信息 <br />
insmod &nbsp;  &nbsp;  &nbsp;  &nbsp; 载入模块 <br />
modprobe &nbsp;  &nbsp;  &nbsp; 自动处理可载入模块 <br />
rmmod &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 删除模块 <br />
chkconfig &nbsp;  &nbsp;  &nbsp; 检查，设置系统的各种服务 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; chkconfig &nbsp; --list &nbsp; -----&gt; 列出各项服务状态 <br />
ntsysv &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置系统的各种服务 <br />
cpio &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 备份文件 <br />
&nbsp;  <br />
<h3>压缩命令： </h3>
&nbsp; *.Z &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; compress &nbsp; 程式壓縮的檔案； &nbsp;  <br />
&nbsp; *.bz2 &nbsp;  &nbsp;  &nbsp;  &nbsp; bzip2 &nbsp; 程式壓縮的檔案； &nbsp;  <br />
&nbsp; *.gz &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; gzip &nbsp; 程式壓縮的檔案； &nbsp;  <br />
&nbsp; *.tar &nbsp;  &nbsp;  &nbsp;  &nbsp; tar &nbsp; 程式打包的資料，並沒有壓縮過； &nbsp;  <br />
&nbsp; *.tar.gz &nbsp; tar &nbsp; 程式打包的檔案，其中並且經過 &nbsp; gzip &nbsp; 的壓縮 <br />
compress &nbsp; filename &nbsp;  &nbsp; 压缩文件 &nbsp;  &nbsp; 加[-d]解压 &nbsp;  &nbsp; uncompress <br />
gzip &nbsp; filename &nbsp;  &nbsp;  &nbsp; 压缩 &nbsp;  &nbsp; 加[-d]解压 &nbsp;  &nbsp; zcat &nbsp; 123.gz &nbsp; 查看压缩文件内容 <br />
bzip2 &nbsp; -z &nbsp; filename &nbsp;  &nbsp; 压缩 &nbsp;  &nbsp; 加[-d]解压 &nbsp;  &nbsp;  &nbsp; bzcat &nbsp; filename.bz2 &nbsp;  &nbsp; 查看压缩文件内容 <br />
tar &nbsp; -cvf &nbsp; /home/123.tar &nbsp; /etc &nbsp;  &nbsp; 打包，不压缩 <br />
tar &nbsp; -xvf &nbsp; 123.tar &nbsp;  &nbsp;  &nbsp; 解开包 <br />
tar &nbsp; -zxvf &nbsp; /home/123.tar.gz &nbsp;  &nbsp; 以gzip解压 <br />
tar &nbsp; -jxvf &nbsp; /home/123.tar.bz2 &nbsp;  &nbsp; 以bzip2解压 <br />
tar &nbsp; -ztvf &nbsp; /tmp/etc.tar.gz &nbsp;  &nbsp;  &nbsp; 查看tar内容 <br />
cpio &nbsp; -covB &nbsp;  &nbsp; &gt;  &nbsp; [file &amp;brvbardevice] &nbsp;  &nbsp;  &nbsp; 份份 <br />
cpio &nbsp; -icduv &nbsp;  &lt; &nbsp; [file &amp;brvbardevice] &nbsp;  &nbsp;  &nbsp; 还原 &nbsp;
<h3> vi一般用法 </h3>
一般模式 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 编辑模式 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 指令模式 <br />
h &nbsp; 左 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; a,i,r,o,A,I,R,O &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :w &nbsp; 保存 <br />
j &nbsp; 下 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 进入编辑模式 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :w! &nbsp; 强制保存 <br />
k &nbsp; 上 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; dd &nbsp; 删除光标当前行 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :q! &nbsp; 不保存离开 <br />
l &nbsp; 右 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ndd &nbsp; 删除n行 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :wq! &nbsp; 保存后离开 <br />
0 &nbsp; 移动到行首 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; yy &nbsp; 复制当前行 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :e! &nbsp; 还原原始档 <br />
$ &nbsp; 移动到行尾 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; nyy &nbsp; 复制n行 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :w &nbsp; filename &nbsp; 另存为 <br />
H &nbsp; 屏幕最上 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; p,P &nbsp; 粘贴 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :set &nbsp; nu &nbsp; 设置行号 <br />
M &nbsp; 屏幕中央 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; u &nbsp; &nbsp; 撤消 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :set &nbsp; nonu &nbsp; 取消行号 <br />
L &nbsp; 屏幕最下 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; [Ctrl]+r &nbsp; 重做上一个动作 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ZZ &nbsp; 保存离开 <br />
G &nbsp; 档案最后一行 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; [ctrl]+z &nbsp; 暂停退出 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; :set &nbsp; nohlsearch &nbsp;  &nbsp;  &nbsp; 永久地关闭高亮显示 <br />
/work &nbsp; 向下搜索 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :sp &nbsp; 同时打开两个文档 &nbsp; <br />
?work &nbsp; 向上搜索 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; [Ctrl]+w &nbsp; 两个文档设换 <br />
gg &nbsp; 移动到档案第一行 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; :nohlsearch &nbsp; &nbsp; &nbsp; &nbsp; 暂时关闭高亮显示 <br />
<h3>  &nbsp;  </h3>
<h3> 认识SHELL </h3>
alias &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示当前所有的命令别名 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; alias &nbsp; lm= &quot;ls &nbsp; -al &quot; &nbsp;  &nbsp;  &nbsp; 命令别名 &nbsp;  &nbsp;  &nbsp;  &nbsp; unalias &nbsp; lm &nbsp; 取消命令别名 <br />
type &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 类似which <br />
exprot &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置或显示环境变量 <br />
exprot &nbsp; PATH= &quot;$PATH &quot;:/sbin &nbsp;  &nbsp; 添加/sbin入PATH路径 <br />
echo &nbsp; $PATH &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示PATH路径 <br />
bash &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 进入子程序 <br />
name=yang &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 设定变量 <br />
unset &nbsp; name &nbsp;  &nbsp;  &nbsp;  &nbsp; 取消变量 <br />
echo &nbsp; $name &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示变量的内容 <br />
myname= &quot;$name &nbsp; its &nbsp; me &quot; &nbsp;  &nbsp;  &nbsp; &amp; &nbsp;  &nbsp;  &nbsp; myname= '$name &nbsp; its &nbsp; me ' &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 单引号时$name失去变量内容 <br />
ciw=/etc/sysconfig/network-scripts/ &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置路径 <br />
env &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 列出所有环境变量 <br />
echo &nbsp; $RANDOM &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示随意产生的数 <br />
set &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置SHELL <br />
PS1= '[\u@\h &nbsp; \w &nbsp; \A &nbsp; #\#]\$ &nbsp;  ' &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 提示字元的設定 <br />
&nbsp;  &nbsp;  &nbsp; [root@linux &nbsp; ~]# &nbsp; read &nbsp; [-pt] &nbsp; variable &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; -----------读取键盘输入的变量 <br />
&nbsp;  &nbsp;  &nbsp; 參數： <br />
&nbsp;  &nbsp;  &nbsp; -p &nbsp;  &nbsp; ：後面可以接提示字元！ <br />
&nbsp;  &nbsp;  &nbsp; -t &nbsp;  &nbsp; ：後面可以接等待的『秒數！』 <br />
declare &nbsp;  &nbsp;  &nbsp;  &nbsp; 声明 &nbsp; shell &nbsp; 变量 <br />
ulimit &nbsp; -a &nbsp;  &nbsp;  &nbsp; 显示所有限制资料 <br />
&nbsp; ls &nbsp; /tmp/yang &nbsp; &amp;&amp; &nbsp; echo &nbsp;  &quot;exist &quot; &nbsp;  &brvbar; &brvbar; &nbsp; echo &nbsp;  &quot;not &nbsp; exist &quot; <br />
&nbsp; 意思是說，當 &nbsp; ls &nbsp; /tmp/yang &nbsp; 執行後，若正確，就執行echo &nbsp;  &quot;exist &quot; &nbsp; ,若有問題，就執行echo &nbsp;  &quot;not &nbsp; exist &quot; &nbsp;  <br />
&nbsp; echo &nbsp; $PATH &nbsp;  &brvbar; &nbsp; cut &nbsp; -d &nbsp;  ': ' &nbsp; -f &nbsp; 5 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 以:为分隔符,读取第5段内容 <br />
&nbsp; export &nbsp;  &brvbar; &nbsp; cut &nbsp; -c &nbsp; 10-20 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 读取第10到20个字节的内容 <br />
&nbsp; last &nbsp;  &brvbar; &nbsp; grep &nbsp;  'root ' &nbsp;  &nbsp;  &nbsp;  &nbsp; 搜索有root的一行,加[-v]反向搜索 <br />
&nbsp; cat &nbsp; /etc/passwd &nbsp;  &brvbar; &nbsp; sort &nbsp;  &nbsp;  &nbsp;  &nbsp; 排序显示 <br />
&nbsp; cat &nbsp; /etc/passwd &nbsp;  &brvbar; &nbsp; wc &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示『行、字数、字节数』 <br />
正规表示法 <br />
[root@test &nbsp; root]# &nbsp; grep &nbsp; [-acinv] &nbsp;  '搜尋字串 ' &nbsp; filename <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 參數說明： <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; -a &nbsp; ：將 &nbsp; binary &nbsp; 檔案以 &nbsp; text &nbsp; 檔案的方式搜尋資料 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; -c &nbsp; ：計算找到 &nbsp;  '搜尋字串 ' &nbsp; 的次數 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; -i &nbsp; ：忽略大小寫的不同，所以大小寫視為相同 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; -n &nbsp; ：順便輸出行號 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; -v &nbsp; ：反向選擇，亦即顯示出沒有 &nbsp;  '搜尋字串 ' &nbsp; 內容的那一行！ <br />
&nbsp; grep &nbsp; -n &nbsp;  'the ' &nbsp; 123.txt &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 搜索the字符 &nbsp; -----------搜尋特定字串 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
&nbsp; grep &nbsp; -n &nbsp;  't[ea]st ' &nbsp; 123.txt &nbsp;  &nbsp;  &nbsp;  &nbsp; 搜索test或taste两个字符---------利用 &nbsp; [] &nbsp; 來搜尋集合字元 <br />
&nbsp; grep &nbsp; -n &nbsp;  '[^g]oo ' &nbsp; 123.txt &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 搜索前面不为g的oo-----------向選擇 &nbsp; [^] &nbsp;  <br />
&nbsp; grep &nbsp; -n &nbsp;  '[0-9] ' &nbsp; 123.txt &nbsp;  &nbsp; 搜索有0-9的数字 <br />
&nbsp; grep &nbsp; -n &nbsp;  '^the ' &nbsp; 123.txt &nbsp; 搜索以the为行首-----------行首搜索^ <br />
&nbsp; grep &nbsp; -n &nbsp;  '^[^a-zA-Z] ' &nbsp; 123.txt &nbsp;  &nbsp; 搜索不以英文字母开头 <br />
&nbsp; grep &nbsp; -n &nbsp;  '[a-z]$ ' &nbsp; 123.txt &nbsp;  &nbsp;  &nbsp;  &nbsp; 搜索以a-z结尾的行---------- &nbsp; 行尾搜索$ <br />
&nbsp; grep &nbsp; -n &nbsp;  'g..d ' &nbsp; 123.txt &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 搜索开头g结尾d字符----------任意一個字元 &nbsp; . &nbsp;  <br />
&nbsp; grep &nbsp; -n &nbsp;  'ooo* ' &nbsp; 123.txt &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 搜索至少有两个oo的字符---------重複字元 &nbsp; * <br />
sed &nbsp;  &nbsp;  &nbsp;  &nbsp; 文本流编辑器 &nbsp;  &nbsp;  &nbsp;  &nbsp; 利用脚本命令来处理文本文件 <br />
awd &nbsp;  &nbsp;  &nbsp;  &nbsp; 模式扫描和处理语言 <br />
&nbsp; nl &nbsp; 123.txt &nbsp;  &brvbar; &nbsp; sed &nbsp;  '2,5d ' &nbsp;  &nbsp;  &nbsp; 删除第二到第五行的内容 <br />
diff &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 比较文件的差异 <br />
cmp &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 比较两个文件是否有差异 <br />
patch &nbsp;  &nbsp;  &nbsp;  &nbsp; 修补文件 <br />
pr &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 要打印的文件格式化 <br />
<br />
<h3>帐号管理 </h3>
/etc/passwd &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统帐号信息 <br />
/etc/shadow &nbsp;  &nbsp;  &nbsp;  &nbsp; 帐号密码信息 &nbsp;  &nbsp;  &nbsp;  &nbsp; 经MD5 &nbsp; 32位加密 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 在密码栏前面加『 &nbsp; * &nbsp; 』『 &nbsp; ! &nbsp; 』禁止使用某帐号 <br />
/etc/group &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 系统群组信息 <br />
/etc/gshadow <br />
newgrp &nbsp;  &nbsp;  &nbsp;  &nbsp; 改变登陆组 <br />
useradd &nbsp;  &nbsp; &amp; &nbsp;  &nbsp; adduser &nbsp;  &nbsp;  &nbsp;  &nbsp; 建立新用户 &nbsp;  &nbsp; ---------&gt;  &nbsp; useradd &nbsp; -m &nbsp; test &nbsp;  &nbsp; 自动建立用户的登入目录 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; useradd &nbsp; -m &nbsp; -g &nbsp; pgroup &nbsp; test &nbsp; ---------&gt; 指定所属级 <br />
/etc/default/useradd &nbsp;  &nbsp;  &nbsp; 相关设定 <br />
/etc/login.defs &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; UID/GID &nbsp; 有關的設定 <br />
passwd &nbsp;  &nbsp;  &nbsp;  &nbsp; 更改密码 &nbsp; -----------&gt;  &nbsp; passwd &nbsp; test <br />
usermod &nbsp;  &nbsp;  &nbsp; 修改用户帐号 <br />
userdel &nbsp;  &nbsp;  &nbsp; 删除帐号 &nbsp; -----------&gt; userdel &nbsp; -r &nbsp; test <br />
chsh &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 更换登陆系统时使用的SHELL &nbsp;  &nbsp;  &nbsp; [-l]显示可用的SHELL;[-s]修改自己的SHELL <br />
chfn &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 改变finger指令显示的信息 <br />
finger &nbsp;  &nbsp;  &nbsp;  &nbsp; 查找并显示用户信息 <br />
id &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示用户的ID &nbsp; -----------&gt;  &nbsp;  &nbsp; id &nbsp; test <br />
groupadd &nbsp;  &nbsp;  &nbsp; 添加组 <br />
groupmod &nbsp;  &nbsp;  &nbsp; 与usermod类似 <br />
groupdel &nbsp;  &nbsp;  &nbsp; 删除组 <br />
su &nbsp; test &nbsp;  &nbsp;  &nbsp;  &nbsp; 更改用户 &nbsp;  &nbsp;  &nbsp; su &nbsp; - &nbsp;  &nbsp;  &nbsp;  &nbsp; 进入root,且使用root的环境变量 <br />
sudo &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 以其他身份来执行指令 <br />
visudo &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 编辑/etc/sudoers &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 加入一行『 &nbsp; test &nbsp; ALL=(ALL) &nbsp; ALL &nbsp; 』 <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; %wheel &nbsp; ALL &nbsp; = &nbsp; (ALL) &nbsp; ALL &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 系统里所有wheel群组的用户都可用sudo <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; %wheel &nbsp; ALL &nbsp; = &nbsp; (ALL) &nbsp; NOPASSWD: &nbsp; ALL &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; wheel群组所有用户都不用密码NOPASSWD <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; User_Alias &nbsp; ADMPW &nbsp; = &nbsp; vbird, &nbsp; dmtsai, &nbsp; vbird1, &nbsp; vbird3 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 加入ADMPW组 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ADMPW &nbsp; ALL &nbsp; = &nbsp; NOPASSWD: &nbsp; !/usr/bin/passwd, &nbsp; /usr/bin/passwd &nbsp; [A-Za-z]*, &nbsp; \ <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; !/usr/bin/passwd &nbsp; root &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 可以更改使用者密码,但不能更改root密码 &nbsp; (在指令前面加入 &nbsp; ! &nbsp; 代表不可) <br />
PAM &nbsp; (Pluggable &nbsp; Authentication &nbsp; Modules, &nbsp; 嵌入式模組) <br />
who &nbsp; &amp; &nbsp; w &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 看谁在线 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  <br />
last &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 最近登陆主机的信息 <br />
lastlog &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 最近登入的時間 &nbsp;  &nbsp;  &nbsp;  &nbsp; 读取 &nbsp; /var/log/lastlog &nbsp;  <br />
talk &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 与其他用户交谈 <br />
write &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 发送信息 &nbsp;  &nbsp;  &nbsp;  &nbsp; write &nbsp; test &nbsp;  &nbsp;  &nbsp; [ctrl]+d &nbsp; 发送 <br />
mesg &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置终端机的写入权限 &nbsp;  &nbsp;  &nbsp;  &nbsp; mesg &nbsp; n &nbsp; 禁止接收 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; mesg &nbsp; y &nbsp;  <br />
wall &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 向所有用户发送信息 &nbsp;  &nbsp;  &nbsp;  &nbsp; wall &nbsp; this &nbsp; is &nbsp; q &nbsp; test <br />
mail &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 写mail &nbsp;  &nbsp;  &nbsp;  <br />
/etc/default/useradd &nbsp;  &nbsp;  &nbsp;  &nbsp; 家目录默认设置 <br />
quota &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 显示磁盘已使用的空间与限制 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; quota &nbsp; -guvs &nbsp; -----&gt; 秀出目前 &nbsp; root &nbsp; 自己的 &nbsp; quota &nbsp; 限制值 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; quota &nbsp; -vu &nbsp;  &nbsp;  &nbsp; 查询 <br />
quotacheck &nbsp; &nbsp; &nbsp; 检查磁盘的使用空间与限制 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; quotacheck &nbsp; -avug &nbsp; &nbsp; -----&gt; 將所有的在 &nbsp; /etc/mtab &nbsp; 內，含有 &nbsp; quota &nbsp; 支援的 &nbsp; partition &nbsp; 進行掃瞄 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; [-m] &nbsp; 强制扫描 &nbsp;  &nbsp;  <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; quota一定要是独立的分区,要有quota.user和quota.group两件文件,在/etc/fstab添加一句: <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; /dev/hda3 &nbsp; /home &nbsp; ext3 &nbsp; defaults,usrquota,grpquota &nbsp; 1 &nbsp; 2 <br />
&nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; chmod &nbsp; 600 &nbsp; quota* &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 设置完成,重启生效 <br />
edquota &nbsp;  &nbsp;  &nbsp;  &nbsp; 编辑用户或群组的quota &nbsp;  &nbsp; [u]用户,[g]群组,[p]复制,[t]设置宽限期限 &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edquota &nbsp; -a &nbsp; yang &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edquota &nbsp; -p &nbsp; yang &nbsp; -u &nbsp; young &nbsp; -----&gt; 复制 &nbsp; &nbsp; &nbsp; &nbsp; <br />
quotaon &nbsp;  &nbsp;  &nbsp;  &nbsp; 开启磁盘空间限制 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; quotaon &nbsp; -auvg &nbsp; --------&gt; 啟動所有的具有 &nbsp; quota &nbsp; 的 &nbsp; filesystem <br />
quotaoff &nbsp;  &nbsp;  &nbsp; 关闭磁盘空间限制 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; quotaoff &nbsp; -a &nbsp;  &nbsp; --------&gt; 關閉了 &nbsp; quota &nbsp; 的限制 <br />
repquota &nbsp; -av &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 查閱系統內所有的具有 &nbsp; quota &nbsp; 的 &nbsp; filesystem &nbsp; 的限值狀態 <br />
Quota &nbsp; 從開始準備 &nbsp; filesystem &nbsp; 的支援到整個設定結束的主要的步驟大概是： <br />
1、設定 &nbsp; partition &nbsp; 的 &nbsp; filesystem &nbsp; 支援 &nbsp; quota &nbsp; 參數： <br />
由於 &nbsp; quota &nbsp; 必須要讓 &nbsp; partition &nbsp; 上面的 &nbsp; filesystem &nbsp; 支援才行，一般來說， &nbsp; 支援度最好的是 &nbsp; ext2/ext3 &nbsp; ， <br />
其他的 &nbsp; filesystem &nbsp; 類型鳥哥我是沒有試過啦！ &nbsp; 啟動 &nbsp; filesystem &nbsp; 支援 &nbsp; quota &nbsp; 最簡單就是編輯 &nbsp; /etc/fstab &nbsp; ， <br />
使得準備要開放的 &nbsp; quota &nbsp; 磁碟可以支援 &nbsp; quota &nbsp; 囉； <br />
2、建立 &nbsp; quota &nbsp; 記錄檔： <br />
剛剛前面講過，整個 &nbsp; quota &nbsp; 進行磁碟限制值記錄的檔案是 &nbsp; aquota.user/aquota.group， &nbsp;  <br />
要建立這兩個檔案就必須要先利用 &nbsp; quotacheck &nbsp; 掃瞄才行喔！ <br />
3、編輯 &nbsp; quota &nbsp; 限制值資料： <br />
再來就是使用 &nbsp; edquota &nbsp; 來編輯每個使用者或群組的可使用空間囉； <br />
4、重新掃瞄與啟動 &nbsp; quota &nbsp; ： <br />
設定好 &nbsp; quota &nbsp; 之後，建議可以再進行一次 &nbsp; quotacheck &nbsp; ，然後再以 &nbsp; quotaon &nbsp; 來啟動吧！ <br />
<br />
开机流程简介 <br />
1、載入 &nbsp; BIOS &nbsp; 的硬體資訊，並取得第一個開機裝置的代號； &nbsp;  <br />
2、讀取第一個開機裝置的 &nbsp; MBR &nbsp; 的 &nbsp; boot &nbsp; Loader &nbsp; (亦即是 &nbsp; lilo, &nbsp; grub, &nbsp; spfdisk &nbsp; 等等) &nbsp; 的開機資訊； &nbsp;  <br />
3、載入 &nbsp; Kernel &nbsp; 作業系統核心資訊， &nbsp; Kernel &nbsp; 開始解壓縮，並且嘗試驅動所有硬體裝置； &nbsp;  <br />
4、Kernel &nbsp; 執行 &nbsp; init &nbsp; 程式並取得 &nbsp; run-level &nbsp; 資訊； &nbsp;  <br />
5、init &nbsp; 執行 &nbsp; /etc/rc.d/rc.sysinit &nbsp; 檔案； &nbsp;  <br />
6、啟動核心的外掛模組 &nbsp; (/etc/modprobe.conf)； &nbsp;  <br />
7、init &nbsp; 執行 &nbsp; run-level &nbsp; 的各個批次檔( &nbsp; Scripts &nbsp; )； &nbsp;  <br />
8、init &nbsp; 執行 &nbsp; /etc/rc.d/rc.local &nbsp; 檔案； &nbsp;  <br />
9、執行 &nbsp; /bin/login &nbsp; 程式，並等待使用者登入； &nbsp;  <br />
10、登入之後開始以 &nbsp; Shell &nbsp; 控管主機。 &nbsp;  <br />
在/etc/rc.d/rc3.d內,以S开头的为开机启动,以K开头的为关闭,接着的数字代表执行顺序 <br />
GRUB &nbsp; vga设定 <br />
彩度\解析度 &nbsp;  &nbsp; 640x480 &nbsp;  &nbsp; 800x600 &nbsp;  &nbsp; 1024x768 &nbsp;  &nbsp; 1280x1024 &nbsp;  &nbsp;  &nbsp; bit &nbsp;  <br />
&nbsp; &nbsp; &nbsp; &nbsp; 256 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 769 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 771 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 773 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 775 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 8 &nbsp; bit &nbsp; <br />
&nbsp; &nbsp; &nbsp; 32768 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 784 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 787 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 790 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 793 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 15 &nbsp; bit &nbsp; <br />
&nbsp; &nbsp; &nbsp; 65536 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 785 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 788 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 791 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 794 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 16 &nbsp; bit &nbsp; <br />
&nbsp; &nbsp; &nbsp; 16.8M &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 786 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 789 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 792 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 795 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 32 &nbsp; bit &nbsp; <br />
<br />
./configure &nbsp;  &nbsp;  &nbsp;  &nbsp; 检查系统信息 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; ./configure &nbsp; --help &nbsp;  &brvbar; &nbsp; more &nbsp;  &nbsp; 帮助信息 <br />
make &nbsp; clean &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 清除之前留下的文件 <br />
make &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; 编译 <br />
make &nbsp; install &nbsp;  &nbsp;  &nbsp; 安装 <br />
rpm &nbsp; -q &nbsp;  &nbsp; -----&gt; 查询是否安装 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; rpm &nbsp; -ql &nbsp; ------&gt; 查询该套件所有的目录 <br />
rpm &nbsp; -qi &nbsp; -----&gt; 查询套件的说明资料 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; rpm &nbsp; -qc[d] &nbsp; -----&gt; 设定档与说明档 <br />
rpm &nbsp; -ivh &nbsp;  &nbsp; ----&gt; 安装 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; rpm &nbsp; -V &nbsp;  &nbsp; --------&gt; 查看套件有否更动过 <br />
rpm &nbsp; -e &nbsp;  &nbsp; ------&gt; 删除 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; rpm &nbsp; -Uvh &nbsp; -------&gt; 升级安装 &nbsp;  &nbsp;  <br />
--nodeps &nbsp; -----&gt; 强行安装 &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp;  &nbsp; --test &nbsp; -----&gt; 测试安装 
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/150341#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sun, 23 Dec 2007 22:51:03 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/150341</link>
        <guid>http://cherryremind.javaeye.com/blog/150341</guid>
      </item>
      <item>
        <title>Use Collection or List ?[JavaSE]</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/141396" style="color:red;">http://cherryremind.javaeye.com/blog/141396</a>&nbsp;
          发表时间: 2007年11月17日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          Question:<br />
使用<br />
&nbsp; Collection &nbsp; param &nbsp; = &nbsp; new &nbsp; ArrayList(); &nbsp; <br />
&nbsp; 还是： &nbsp; <br />
&nbsp; List &nbsp; param &nbsp; = &nbsp; new &nbsp; ArrayList(); &nbsp; <br />
&nbsp;  &nbsp; <br />
&nbsp; Answer:<br />
<br />
将一个对象向上转型为父类类型或接口类型，意味着你只能对该对象调用父类或接口中定义的方法。 &nbsp; <br />
&nbsp;  &nbsp; <br />
&nbsp; List和Collection都是接口，但List继承自（或者更应该叫扩展自）Collection，自然比Collection定义的方法多得多。具体哪些差别，可以自己去查JAVADOC。 &nbsp; <br />
&nbsp;  &nbsp; <br />
&nbsp; 比如一个很明显的问题就是：用Collection接口的话，那么你只能add()，不能get()，因为Collection中没有定义get()方法。 &nbsp; <br />
&nbsp;  &nbsp; <br />
&nbsp; 另外一个很明显的区别是：List能返回一个更加有用的迭代器ListIterator，而Collection只能返回普通迭代器。 &nbsp; <br />
&nbsp;  &nbsp; <br />
&nbsp; 一般来说，向上转型的作用是限制对象的行为与接口保持一致，所以如果你要你的对象的行为和Collection保持一致，就转型为Collection， 要和List保持一致，就转型为List。这是灵活性和功能性的一个权衡。通常转型为Collection并不是十分必要，因为Collection提供 的接口实在太有限了。<br />
<br />
<br />
<br />
<br />
<p><strong><font color="#0000ff">Collection接口</font></strong><br />
Collection是最基本的集合接口，一个Collection代表一组Object，即Collection的元素（Elements）。一些 Collection允许相同的元素而另一些不行。一些能排序而另一些不行。Java SDK不提供直接继承自Collection的类，Java SDK提供的类都是继承自Collection的&ldquo;子接口&rdquo;如List和Set。<br />
所有实现Collection接口的类都必须提供两个标准的 构造函数：无参数的构造函数用于创建一个空的Collection，有一个Collection参数的构造函数用于创建一个新的Collection，这 个新的Collection与传入的Collection有相同的元素。后一个构造函数允许用户复制一个Collection。<br />
如何遍历Collection中的每一个元素？不论Collection的实际类型如何，它都支持一个iterator()的方法，该方法返回一个迭代子，使用该迭代子即可逐一访问Collection中每一个元素。典型的用法如下：<br />
<font color="#336666" face="Courier New">　　　　Iterator it = collection.iterator(); // 获得一个迭代子<br />
while(it.hasNext()) {<br />
Object obj = it.next(); // 得到下一个元素<br />
}</font><br />
由Collection接口派生的两个接口是List和Set。</p>
<p><font color="#0000ff"><strong>List接口</strong></font><br />
List是有序的Collection，使用此接口能够精确的控制每个元素插入的位置。用户能够使用索引（元素在List中的位置，类似于数组下标）来访问List中的元素，这类似于Java的数组。<br />
和下面要提到的Set不同，List允许有相同的元素。<br />
除了具有Collection接口必备的iterator()方法外，List还提供一个listIterator()方法，返回一个 ListIterator接口，和标准的Iterator接口相比，ListIterator多了一些add()之类的方法，允许添加，删除，设定元素， 还能向前或向后遍历。<br />
实现List接口的常用类有LinkedList，ArrayList，Vector和Stack。</p>
<p><font color="#0000ff"><strong>LinkedList类</strong></font><br />
LinkedList实现了List接口，允许null元素。此外LinkedList提供额外的get，remove，insert方法在 LinkedList的首部或尾部。这些操作使LinkedList可被用作堆栈（stack），队列（queue）或双向队列（deque）。<br />
注意LinkedList没有同步方法。如果多个线程同时访问一个List，则必须自己实现访问同步。一种解决方法是在创建List时构造一个同步的List：<br />
<font color="#336666" face="Courier New">　　　　List list = Collections.synchronizedList(new LinkedList(...));</font></p>
<p><font color="#0000ff"><strong>ArrayList类</strong></font><br />
ArrayList实现了可变大小的数组。它允许所有元素，包括null。ArrayList没有同步。<br />
size，isEmpty，get，set方法运行时间为常数。但是add方法开销为分摊的常数，添加n个元素需要O(n)的时间。其他的方法运行时间为线性。<br />
每个ArrayList实例都有一个容量（Capacity），即用于存储元素的数组的大小。这个容量可随着不断添加新元素而自动增加，但是增长算法并 没有定义。当需要插入大量元素时，在插入前可以调用ensureCapacity方法来增加ArrayList的容量以提高插入效率。<br />
和LinkedList一样，ArrayList也是非同步的（unsynchronized）。</p>
<p><font color="#0000ff"><strong>Vector类</strong></font><br />
Vector非常类似 ArrayList，但是Vector是同步的。由Vector创建的Iterator，虽然和ArrayList创建的Iterator是同一接口，但 是，因为Vector是同步的，当一个Iterator被创建而且正在被使用，另一个线程改变了Vector的状态（例如，添加或删除了一些元素），这时 调用Iterator的方法时将抛出ConcurrentModificationException，因此必须捕获该异常。</p>
<p><strong><font color="#0000ff">Stack 类</font></strong><br />
Stack继承自 Vector，实现一个后进先出的堆栈。Stack提供5个额外的方法使得Vector得以被当作堆栈使用。基本的push和pop方法，还有peek方 法得到栈顶的元素，empty方法测试堆栈是否为空，search方法检测一个元素在堆栈中的位置。Stack刚创建后是空栈。</p>
<p><font color="#0000ff"><strong>Set接口</strong></font><br />
Set是一种不包含重复的元素的Collection，即任意的两个元素e1和e2都有e1.equals(e2)=false，Set最多有一个null元素。<br />
很明显，Set的构造函数有一个约束条件，传入的Collection参数不能包含重复的元素。<br />
请注意：必须小心操作可变对象（Mutable Object）。如果一个Set中的可变元素改变了自身状态导致Object.equals(Object)=true将导致一些问题。</p>
<p><font color="#0000ff"><strong>Map接口</strong></font><br />
请注意，Map没有继承 Collection接口，Map提供key到value的映射。一个Map中不能包含相同的key，每个key只能映射一个value。Map接口提供 3种集合的视图，Map的内容可以被当作一组key集合，一组value集合，或者一组key-value映射。</p>
<p><font color="#0000ff"><strong>Hashtable类</strong></font><br />
Hashtable继承Map接口，实现一个key-value映射的哈希表。任何非空（non-null）的对象都可作为key或者value。<br />
添加数据使用put(key, value)，取出数据使用get(key)，这两个基本操作的时间开销为常数。<br />
Hashtable 通过initial capacity和load factor两个参数调整性能。通常缺省的load factor 0.75较好地实现了时间和空间的均衡。增大load factor可以节省空间但相应的查找时间将增大，这会影响像get和put这样的操作。<br />
使用Hashtable的简单示例如下，将1，2，3放到Hashtable中，他们的key分别是&rdquo;one&rdquo;，&rdquo;two&rdquo;，&rdquo;three&rdquo;：<br />
<font color="#336666" face="Courier New">　　　　Hashtable numbers = new Hashtable();<br />
numbers.put(&ldquo;one&rdquo;, new Integer(1));<br />
numbers.put(&ldquo;two&rdquo;, new Integer(2));<br />
numbers.put(&ldquo;three&rdquo;, new Integer(3));</font><br />
要取出一个数，比如2，用相应的key：<br />
<font color="#336666" face="Courier New">　　　　Integer n = (Integer)numbers.get(&ldquo;two&rdquo;);<br />
System.out.println(&ldquo;two = &rdquo; + n);</font><br />
由于作为key的对象将通过计算其散列函数来确定与之对应的value的位置，因此任何作为key的对象都必须实现hashCode和equals方 法。hashCode和equals方法继承自根类Object，如果你用自定义的类当作key的话，要相当小心，按照散列函数的定义，如果两个对象相 同，即obj1.equals(obj2)=true，则它们的hashCode必须相同，但如果两个对象不同，则它们的hashCode不一定不同，如 果两个不同对象的hashCode相同，这种现象称为冲突，冲突会导致操作哈希表的时间开销增大，所以尽量定义好的hashCode()方法，能加快哈希 表的操作。<br />
如果相同的对象有不同的hashCode，对哈希表的操作会出现意想不到的结果（期待的get方法返回null），要避免这种问题，只需要牢记一条：要同时复写equals方法和hashCode方法，而不要只写其中一个。<br />
Hashtable是同步的。</p>
<p><strong><font color="#0000ff">HashMap类</font></strong><br />
HashMap和 Hashtable类似，不同之处在于HashMap是非同步的，并且允许null，即null value和null key。，但是将HashMap视为Collection时（values()方法可返回Collection），其迭代子操作时间开销和HashMap 的容量成比例。因此，如果迭代操作的性能相当重要的话，不要将HashMap的初始化容量设得过高，或者load factor过低。</p>
<p><font color="#0000ff"><strong>WeakHashMap类</strong></font><br />
WeakHashMap是一种改进的HashMap，它对key实行&ldquo;弱引用&rdquo;，如果一个key不再被外部所引用，那么该key可以被GC回收。</p>
<p><font color="#ff0000"><strong>总结</strong></font><br />
如果涉及到堆栈，队列等操作，应该考虑用List，对于需要快速插入，删除元素，应该使用LinkedList，如果需要快速随机访问元素，应该使用ArrayList。<br />
如果程序在单线程环境中，或者访问仅仅在一个线程中进行，考虑非同步的类，其效率较高，如果多个线程可能同时操作一个类，应该使用同步的类。<br />
要特别注意对哈希表的操作，作为key的对象要正确复写equals和hashCode方法。<br />
尽量返回接口而非实际的类型，如返回List而非ArrayList，这样如果以后需要将ArrayList换成LinkedList时，客户端代码不用改变。这就是针对抽象编程。</p>
<p align="right">（参考：Sun JDK1.4.1 API DOC）</p>
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/141396#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Sat, 17 Nov 2007 17:15:35 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/141396</link>
        <guid>http://cherryremind.javaeye.com/blog/141396</guid>
      </item>
      <item>
        <title>Design Patterns and OOP</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/134674" style="color:red;">http://cherryremind.javaeye.com/blog/134674</a>&nbsp;
          发表时间: 2007年10月23日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p>
<table cellspacing="0" border="0" align="center" width="628" cellpadding="0">
<tbody>
<tr>
<td>
<h1><span class="css-BodyTitle">Design Patterns</span>

</h1>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td>A design pattern is a recurring solution to a standard problem.<br />

            <br />

            The most well-known design patterns (in total 23) were documented by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides also called The Gang of Four (GOF) in the book <span class="css-TextEmphasize">Design Patterns -- Elements of Reusable Software (1995).</span>

<br />

            <br />

            There a hunderds of design patterns described in the literature. This tutorial only describes the design patterns documented by the GOF.<br />

            <br />

            The GOF has divided the design patterns into three types.<br />

            <br />

            
<table class="css-Table558px" cellspacing="1" border="0" width="558" cellpadding="3">
<tbody>
<tr valign="middle">
<td class="css-TableHeader">Type name</td>
<td class="css-TableHeader">Description</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold"><a href="http://www.mobilefish.com/tutorials/design_patterns/design_patterns.html#creational_patterns" onfocus="this.blur()">Creational patterns</a>

</td>
<td class="css-TableData">Deal with initializing and configuring classes and objects<br />

                        
<ul>
<li>Abstract Factory</li>
<li>Builder Factory</li>
<li>Factory Method</li>
<li>Prototype Factory</li>
<li>Singleton</li>
</ul>
</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold"><a href="http://www.mobilefish.com/tutorials/design_patterns/design_patterns.html#structural_patterns" onfocus="this.blur()">Structural patterns</a>

</td>
<td class="css-TableData">Deal with decoupling interface and implementation of classes and objects<br />

                        
<ul>
<li>Adapter</li>
<li>Bridge</li>
<li>Composite</li>
<li>Decorator</li>
<li>Facade</li>
<li>Flyweight</li>
<li>Proxy</li>
</ul>
</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold"><a href="http://www.mobilefish.com/tutorials/design_patterns/design_patterns.html#behavioral_patterns" onfocus="this.blur()">Behavioral patterns</a>

</td>
<td class="css-TableData">Deal with dynamic interactions among societies of classes and objects<br />

                        
<ul>
<li>Chain of Responsibility</li>
<li>Command</li>
<li>Interpreter</li>
<li>Iterator</li>
<li>Mediator</li>
<li>Memento</li>
<li>Observer</li>
<li>State</li>
<li>Strategy</li>
<li>Template</li>
<li>Visitor</li>
</ul>
</td>
</tr>
</tbody>
</table>
<br />

            <br />

            <a name="creational_patterns" title="creational_patterns" id="creational_patterns"></a>

<span class="css-SectionTitle">Creational patterns.</span>

<br />

            <br />

            
<table class="css-Table558px" cellspacing="1" border="0" width="558" cellpadding="3">
<tbody>
<tr valign="middle">
<td class="css-TableHeader">Name</td>
<td class="css-TableHeader">Description</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold">Factory Method</td>
<td class="css-TableData">Method in a derived class creates associates</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold">Abstract Factory</td>
<td class="css-TableData">Factory for building related objects</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold">Builder</td>
<td class="css-TableData">Factory for building complex objects incrementally</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold">Prototype</td>
<td class="css-TableData">Factory for cloning new instances from a prototype</td>
</tr>
<tr valign="middle">
<td class="css-TableDataBold">Singleton</td>
<td class="css-TableData">Factory for a singular (sole) instance</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>knowledge of pattern<br />
#&nbsp; creational<br />
1. factory method: lazy initialize specific instance <br />
<br />
2. abstract factory: supply a interface for the system<br />
<br />
3. builder: builder or create a object apart from its descrition<br />
<br />
4. prototype: create new object which type base on the type of specific instance<br />
<br />
5. singleton: make sure one class only have one instance, supply for every visitor<br />
&nbsp;allways used with factory pattern together.<br />
<br />
# structural<br />
6. adapter: give a interface of class for get another required interface, implement compatibility <br />
<br />
7. bridge: extranet abstract class from implement class, make it suit for their single change<br />
public abtract class AbstractRoot<br />
{<br />
&nbsp;&nbsp;&nbsp; operation();<br />
}<br />
<br />
8. composite: make a object as tree structure, make &quot;part-all&quot; clearly.&nbsp; </p>
<p>组合模式:&nbsp; ----继承<br />
<br />
9. decorator: change extend(8) to delegate</p>
<p>装饰器模式: --- 委托<br />
<br />
<br />
<br />
10. facade: supply a interface for visiting the sub-system</p>
<p><br />
<br />
11. flyweight: it seem logic like cache.<br />
&nbsp;&nbsp;&nbsp; &nbsp;if (flyweight[key] exists)<br />
&nbsp;&nbsp;&nbsp; &nbsp;{<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return existing flyweight;<br />
&nbsp;&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp;&nbsp; &nbsp;else<br />
&nbsp;&nbsp;&nbsp; &nbsp;{<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; create new flyweight;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; add it to pool of flyweights;<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return the new flyweight;<br />
&nbsp;&nbsp;&nbsp; &nbsp;}<br />
&nbsp;&nbsp;&nbsp; &nbsp;<br />
12. proxy:&nbsp;&nbsp; a, remote proxy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; visit<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;b, virtual proxy&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; performance<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;c, protection proxy&nbsp;&nbsp; control<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;d, smart reference&nbsp;&nbsp;&nbsp; get reference number<br />
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;<br />
# behavioral<br />
13. interpreter 解释模式<br />
<br />
14. Template Method 模版模式&nbsp; <br />
AIM: 定义一个操作中的算法的骨架，而将一些步骤延迟到子类中。<br />
ENV: 一次性实现一个算法的不变的部分，并将可变的行为留给子类来实现.<br />
TODO: 比较组合模式<br />
&nbsp;<br />
15. Chain of Responsibility<br />
AIM: 使多个对象都有机会处理请求，从而避免请求的发送者和接收者之间的耦合关系。将这些对象连成一条链，并沿着这条链传递该请求，直到有一个对象处理它为止.<br />
有多个的对象可以处理一个请求，哪个对象处理该请求运行时刻自动确定。 <br />
你想在不明确指定接收者的情况下，向多个对象中的一个提交一个请求。 <br />
可处理一个请求的对象集合应被动态指定。<br />
<br />
16. Command 命令模式<br />
将一个请求封装为一个对象，从而使你可用不同的请求对客户进行参数化；对请求排队或记录请求日志，以及支持可撤消的操作。<br />
<br />
<br />
17. Iterator 迭代模式<br />
<br />
18. Mediator 仲裁模式<br />
<br />
19. Memento&nbsp; 记忆模式<br />
<br />
20. Observer 观察者模式<br />
<br />
21. State 状态模式<br />
允许一个对象在其内部状态改变时改变它的行为。对象看起来似乎修改了它的类。<br />
<br />
22. Strategy 策略模式<br />
TODO: 比较State<br />
定义一系列的算法,把它们一个个封装起来, 并且使它们可相互替换。本模式使得算法可独立于使用它的客户而变化。<br />
<br />
23. Vistor 访问模式<br />
<br />
&nbsp;<br />
<br />
&nbsp; &lt;head first ooad&gt;</p>
<p>感觉OO原则其实我们平时编码的最基本原则, 设计模式可以就是遵循的OO原则来运用的.<br />
OO principle <br />
#1 the open-closed principle(ocp)<br />
classed shoulde be open for extension, and closed for modification.<br />
<br />
#2 the don't repeat yourself principle (DRY)<br />
have each piece of imformation and behavior in your system in a single,sensible place.<br />
<br />
#3 the single responsibility principle(SRP)<br />
Single responsibility priciple correctly when each of your objects has only one reason to change<br />
<br />
#4 the Liskov substitution priinciple(LSP)<br />
感觉LSP就是用委托....</p>
<p>&nbsp;</p>
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/134674#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Tue, 23 Oct 2007 10:49:35 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/134674</link>
        <guid>http://cherryremind.javaeye.com/blog/134674</guid>
      </item>
      <item>
        <title>Interesting letter[转] </title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/110474" style="color:red;">http://cherryremind.javaeye.com/blog/110474</a>&nbsp;
          发表时间: 2007年08月09日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          <p class="MsoNormal"><span lang="EN-US">One day an employee sends a letter to his boss asking for an increase in his salary! <br />
Dear Bo$$ <br />
In thi$ life, we all need $ome thing mo$t de$perately. I think you $hould be under$tanding of the need$ of u$ worker$ who have given $o much $upport including $weat and $ervice to your company. <br />
I am$ure you will gue$$ what I mean and re$pond $oon. <br />
Your$ $incerely, <br />
Norman $oh <br />
</span><span style="font-family: 宋体;">一名公司雇员某天给老板写信请求加薪。</span><span lang="EN-US"> <br />
</span><span style="font-family: 宋体;">亲爱的老板：</span><span lang="EN-US"> <br />
</span><span style="font-family: 宋体;">人的一生我们都迫切一种东西。大家一直为公司挥汗付出，我想你应该理解我们的需要。</span><span lang="EN-US"> <br />
</span><span style="font-family: 宋体;">我相信你会猜到我的意思并能及时回复。</span><span lang="EN-US"> <br />
</span><span style="font-family: 宋体;">诚挚的</span><span lang="EN-US"> <br />
</span><span style="font-family: 宋体;">诺曼</span><span lang="EN-US">.</span><span style="font-family: 宋体;">苏</span><span lang="EN-US"> <br />
The next day, the employee received this letter of reply: <br />
Dear NOrman, <br />
I kNOw you have been working very hard. NOwadays, NOthing much has changed. You must have NOticed that our company is NOt doing NOticeably well as yet. <br />
NOw the newspaper are saying the world&rsquo;s leading ecoNOmists are NOt sure if the <st1:country-region w:st="on"><st1:place w:st="on">United States</st1:place></st1:country-region> may go into aNOther recession. After the NOvember presidential elections things may turn bad. <br />
I have NOthing more to add NOw. you kNOw what I mean.<o:p></o:p></span></p>
<span style="font-size: 10.5pt; font-family: 宋体;">第二天，雇员收到了回信：</span><span lang="EN-US" style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;;"> <br />
</span><span style="font-size: 10.5pt; font-family: 宋体;">亲爱的诺曼，</span><span lang="EN-US" style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;;"> <br />
</span><span style="font-size: 10.5pt; font-family: 宋体;">我知道你一直工作努力。当前，情况没有多大改观。你肯定也注意到了我们公司业绩平平。</span><span lang="EN-US" style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;;"> <br />
</span><span style="font-size: 10.5pt; font-family: 宋体;">报纸上说，世界知名经济学家们对美国是否会再度进入经济衰退还难下定论。也许过了十一月份的总统选举后情况会更糟。</span><span lang="EN-US" style="font-size: 10.5pt; font-family: &quot;Times New Roman&quot;;"> <br />
</span><span style="font-size: 10.5pt; font-family: 宋体;">其它不多说了。你现在也该明白我的意思了</span>
          <br/><br/>
          <span style="color:red;">
            <a href="http://cherryremind.javaeye.com/blog/110474#comments" style="color:red;">已有 <strong>0</strong> 人发表留言，猛击-&gt;&gt;<strong>这里</strong>&lt;&lt;-参与讨论</a>
          </span>
          <br/><br/><br/>
          <span style="color:#E28822;">JavaEye推荐</span>
          <br/>
          <ul class='adverts'><li><a href='/adverts/42' target='_blank'><span style="color:red;font-weight:bold;">搜狐网站诚聘Java、PHP和C++工程师</span></a></li><li><a href='/adverts/41' target='_blank'><span style="color:red;font-weight:bold;">北京: 千橡集团暨校内网诚聘软件研发工程师</span></a></li></ul>
          <br/><br/><br/>
          ]]>
        </description>
        <pubDate>Thu, 09 Aug 2007 09:25:52 +0800</pubDate>
        <link>http://cherryremind.javaeye.com/blog/110474</link>
        <guid>http://cherryremind.javaeye.com/blog/110474</guid>
      </item>
      <item>
        <title>XStream体验</title>
        <author>CherryRemind</author>
        <description>
          <![CDATA[
          <br/>
          作者: <a href="http://cherryremind.javaeye.com">CherryRemind</a>&nbsp;
          链接：<a href="http://cherryremind.javaeye.com/blog/101572" style="color:red;">http://cherryremind.javaeye.com/blog/101572</a>&nbsp;
          发表时间: 2007年07月16日
          <br/><br/>
          声明：本文系JavaEye网站发布的原创博客文章，未经作者书面许可，严禁任何网站转载本文，否则必将追究法律责任！
          <br/><br/>
          XML常用的sax dom解析<br />
<br />
XStream 的网站<br />
<a href="http://xstream.codehaus.org/">xstream.codehaus.org/</a><br />
看到JE上人说用XStream对XML读写不错,去看了下,在xstream的网站上有很详细的例程,这里就不多说了,都能看明白<br />
<br />
<br />
XStream可以根据需要,写出想要的XML 的格式,<br />
例如常见的&nbsp; Hibernate 一个pojo类的配置文件 如下<br />
<hibernate-mapping package="com"><class name="Person" table="novem"><id name="id" column="ID" type="integer">
<div class="code_title">xml 代码</div>
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-xml" start="1">
    <li class="alt"><span><span class="tag">&lt;?</span><span class="tag-name">xml</span><span>&nbsp;</span><span class="attribute">version</span><span>=</span><span class="attribute-value">&quot;1.0&quot;</span><span>&nbsp;</span><span class="attribute">encoding</span><span>=</span><span class="attribute-value">&quot;UTF-8&quot;</span><span class="tag">?&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&lt;!DOCTYPE&nbsp;hibernate-mapping&nbsp;PUBLIC&nbsp;&quot;-//Hibernate/Hibernate&nbsp;Mapping&nbsp;DTD&nbsp;3.0//EN&quot;&nbsp;&quot;http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd&quot;&nbsp;<span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="tag">&lt;</span><span class="tag-name">hibernate-mapping</span><span>&nbsp;</span><span class="attribute">package</span><span>=</span><span class="attribute-value">&quot;com&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">class</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;Person&quot;</span><span>&nbsp;</span><span class="attribute">table</span><span>=</span><span class="attribute-value">&quot;novem&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">id</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;id&quot;</span><span>&nbsp;</span><span class="attribute">column</span><span>=</span><span class="attribute-value">&quot;ID&quot;</span><span>&nbsp;</span><span class="attribute">type</span><span>=</span><span class="attribute-value">&quot;integer&quot;</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">generator</span><span>&nbsp;</span><span class="attribute">class</span><span>=</span><span class="attribute-value">&quot;increment&quot;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;/</span><span class="tag-name">id</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">property</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;name&quot;</span><span>&nbsp;</span><span class="attribute">column</span><span>=</span><span class="attribute-value">&quot;NAME&quot;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="tag">&lt;</span><span class="tag-name">property</span><span>&nbsp;</span><span class="attribute">name</span><span>=</span><span class="attribute-value">&quot;email&quot;</span><span>&nbsp;</span><span class="attribute">column</span><span>=</span><span class="attribute-value">&quot;EMAIL&quot;</span><span class="tag">/&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;<span class="tag">&lt;/</span><span class="tag-name">class</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="tag">&lt;/</span><span class="tag-name">hibernate-mapping</span><span class="tag">&gt;</span><span>&nbsp;&nbsp;</span></span></li>
</ol>
</div>
<property name="name" column="NAME"><br />
&nbsp; </property>
<br />
生成代码如下:<br />
</id></class></hibernate-mapping>
<div class="code_title">java 代码</div>
<div class="dp-highlighter">
<div class="bar">&nbsp;</div>
<ol class="dp-j" start="1">
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;java.io.BufferedWriter;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;java.io.File;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;java.io.FileNotFoundException;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;java.io.FileWriter;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;java.io.IOException;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;java.util.ArrayList;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;java.util.List;&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;</span></li>
    <li class="alt"><span><span class="keyword">import</span><span>&nbsp;com.thoughtworks.xstream.XStream;&nbsp;&nbsp;</span></span></li>
    <li class=""><span><span class="keyword">import</span><span>&nbsp;com.thoughtworks.xstream.io.xml.DomDriver;&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span><span class="keyword">public</span><span>&nbsp;</span><span class="keyword">class</span><span>&nbsp;createHbmXmlTest&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;</span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">/**</span>&nbsp;</span></li>
    <li class="alt"><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*&nbsp;@param&nbsp;args</span>&nbsp;</span></li>
    <li class=""><span><span class="comment">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&nbsp;&nbsp;<span class="keyword">public</span><span>&nbsp;</span><span class="keyword">static</span><span>&nbsp;</span><span class="keyword">void</span><span>&nbsp;main(String[]&nbsp;args)&nbsp;{&nbsp;&nbsp;</span></span></li>
    <li class=""><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="comment">//&nbsp;TODO&nbsp;Auto-generated&nbsp;method&nbsp;stub</span><span>&nbsp;&nbsp;</span></span></li>
    <li class="alt"><span>&nbsp;&nbsp;&