Ubuntu Linux Change Hostname (computer name) 2016

Iam a new Ubuntu Linux laptop user. I setup my computer name to 'tom' during installation but now I would like to change the computer name to 'jerry'. How can I remove tom and set it to jerry on Ubuntu Linux? How do I change the Ubuntu computer name from 'ubuntu' to 'AvlinStar'?

You can use the hostname command to see or set the system's host name. The host name or computer name is usually at system startup in /etc/hostname file. Open the terminal application and type the following command.



Display the current Ubuntu hostname

Simply type the following command:
$ hostname
Sample outputs:



Ubuntu change hostname command

The procedure to change the computer name on Ubuntu Linux:
  1. Type the following command to edit /etc/hostname using nano or vi text editor:
    sudo nano /etc/hostname
    Delete the old name and setup new name.
  2. Next Edit the /etc/hosts file:
    sudo nano /etc/hosts
    Replace any occurrence of the existing computer name with your new one.
  3. Reboot the system to changes take effect:
    sudo reboot
Sample outputs:
Gif 01: Ubuntu change the computer name demo
Gif 01: Ubuntu change the computer name demo

How to change the Ubuntu server hostname without a system restart?

Type the following commands:
$ sudo hostname new-server-name-here
Next edit the /etc/hostname file and update hostname:
$ sudo nano /etc/hostname
Finally, edit the /etc/hostname file and update the lines that reads your old-host-name:
$ sudo nano /etc/hostname
From:
127.0.1.1 old-host-name
To:
127.0.1.1 new-server-name-here
Save and close the file.

No comments :