ubuntu set host name

时间:2022-04-28 08:23:39

http://wiki.joyent.com/wiki/display/jpc2/Setting+the+Host+Name+on+a+Linux+VM

  • Set the host name in the /etc/hostname file:
    echo "ubuntu.example.com" > /etc/hostname
  • Using any text editor, edit the file /etc/hosts so that the hostname points to the localhost address:
    127.0.0.1       localhost
    127.0.1.1       ubuntu.example.com localhost
      
    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
  • Invoke the host name initialization script(if following command not work, you can reboot system).
    start hostname