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:
$ hostname
Output:
vivek-desktop.gite.in
Task: Change hostname
Set hostname to desktop.nixcraft.com:
# hostname desktop.nixcraft.com
# hostname
Output:
desktop.nixcraft.com
Task: Change hostname permanently
You need to edit a file called /etc/hostname:
# vi /etc/hostname
Set new hostname:
desktop.nixcraft.com
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.
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- My 10 UNIX Command Line Mistakes
- 10 Greatest Open Source Software Of 2009
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
- Email FAQ to a friend
- Download PDF version
- Printable version
- Comment RSS feed
- Last Updated: 07/26/07



{ 1 comment… read it below or add one }
Thanks. That’s exactly what I needed!