I am 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’. Can you tell me how do I I remove tom and set it to jerry on Ubuntu Linux? How do I change the Ubuntu computer name from ‘ubuntu’ to ‘AvlinStar’? Can you tell me more about Ubuntu Linux change hostname command?
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 commands to set or change hostname or computer name on Ubuntu.
Display the current Ubuntu hostname
Simply type the following command:
Ubuntu change hostname command
The procedure to change the computer name on Ubuntu Linux:
- 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.
- Next Edit the /etc/hosts file:
sudo nano /etc/hosts
Replace any occurrence of the existing computer name with your new one.
- Reboot the system to changes take effect:
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/hosts file and update the lines that reads your old-host-name:
$ sudo nano /etc/hosts
Save and close the file.
Ubuntu Linux Change Hostname Using hostnamectl
Systemd based Linux distro such as Ubuntu Linux 16.04 LTS and above can simply use the hostnamectl command to change hostname. To see current setting just type the following command:
Static hostname: nixcraft Icon name: computer-laptop Chassis: laptop Machine ID: 291893e6499e4d99891c3cf4b70a138b Boot ID: 9fda2365b77841649e40a141fde46537 Operating System: Ubuntu 17.10 Kernel: Linux 4.13.0-21-generic Architecture: x86-64
To change hostname from nixcraft to viveks-laptop, enter:
$ hostnamectl set-hostname viveks-laptop