2012-07-23

How to change the hostname in Linux

  1. See hostname
    hostname
    
    OR
    sysctl kernel.hostname
    
  2. Set the new hostname
    hostname NEW_HOSTNAME
    
    OR
    sysctl kernel.hostname=NEW_HOSTNAME
    
  3. Permanent change
    • on Ubuntu and any others based on Debian
      vi /etc/hostname
      
      replace OLD_HOSTNAME with NEW_HOSTNAME
      service hostname start
      
    • on CentOS and any others based on Redhat
      vi /etc/sysconfig/network
      
      replace HOSTNAME="OLD_HOSTNAME" with NEW_HOSTNAME
      /etc/rc.d/rc.sysinit
      

No comments:

Post a Comment