how to change FQDN in ubuntu

9,530

Edit /etc/hostname and put ubuntu

echo "ubuntu" > /etc/hostname

Put hostname entry as well in following format in /etc/hosts

IP  fqdn   hostname

Your /etc/hosts should look like

  127.0.0.1   localhost
  127.0.1.1   ubuntu.example.com  ubuntu
  192.168.217.129 ubuntu.example.com  ubuntu 
# The following lines are desirable for IPv6 capable hosts
Share:
9,530

Related videos on Youtube

THARAKA SANDARUWAN
Author by

THARAKA SANDARUWAN

Updated on September 18, 2022

Comments

  • THARAKA SANDARUWAN
    THARAKA SANDARUWAN over 1 year

    I tried to change the FQDN in Ubuntu using sudo -i gedit /etc/hosts and change as shown below:

    127.0.0.1   localhost
    127.0.1.1   ubuntu.example.com
    192.168.217.129 ubuntu.example.com
    
    # The following lines are desirable for IPv6 capable hosts
    ::1     ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    

    after that I tried:

    hostname -f 
    

    which shows:

    hostname: Name or service not known
    

    How can I change the FQDN?

    • Hussain7
      Hussain7 over 8 years
      The below link will help you. askubuntu.com/questions/158957/…
    • Kinnectus
      Kinnectus over 8 years
      Try the most popular answer here: askubuntu.com/questions/158957/…
    • Kinnectus
      Kinnectus over 8 years
      Well what'ya know!
    • Thufir
      Thufir over 7 years
      rather than using sudo with gedit, might I suggest nano? It's quite easy. Occasionaly, vi is the only real option -- but I think that's realistically only for visudo. I wouldn't mix gedit and sudo, myself.