Q. I’m using Ubuntu Linux. How do I change my hostname or the machine name?
A.. You need to use hostname command, which is used to either set or display the current host or domain name of the system. This name is used by many of the networking programs to identify the machine.
Following instructions should work on both Debian and Ubuntu Linux systems.
Task: Display current hostname
Just type hostname command print the name of the system:
Task: Change hostname
Set hostname to desktop.nixcraft.com:
# hostname desktop.nixcraft.com
Task: Change hostname permanently
You need to edit a file called /etc/hostname:
# vi /etc/hostname
Set new hostname:
Save and close the file.
A note for Redhat / CentOS Linux users
If you are using CentOS or Fedora or Redhat (RHEL) Linux, see this FAQ.Share this tutorial on: