If you’ve ever needed to change the hostname for Red Hat Linux, CentOS or similar operating systems, you can do so easily with one simple command.

Just use the echo command to replace the contents of /proc/sys/kernel/hostname with your new host name.

# echo hostname.com > /proc/sys/kernel/hostname

Then restart the network interfaces:

# /etc/init.d/network restart 
Shutting down interface venet0:  [  OK  ] 
Shutting down loopback interface:  [  OK  ] 
Bringing up loopback interface:  [  OK  ] 
Bringing up interface venet0: RTNETLINK answers: File exists 
RTNETLINK answers: File exists 
[  OK  ]

Now you can use the hostname command to verify that it has changed.

Profile Photo for Lowell Heddings Lowell Heddings
Lowell is the founder and CEO of How-To Geek. Heโ€™s been running the show since creating the site back in 2006. Over the last decade, Lowell has personally written more than 1000 articles which have been viewed by over 250 million people. Prior to starting How-To Geek, Lowell spent 15 years working in IT doing consulting, cybersecurity, database management, and programming work.
Read Full Bio ยป

The above article may contain affiliate links, which help support How-To Geek.