Change the hostname in CentOS from the command line

Open an SSH session to your server and edit the following file (with nano, or vim, or any other editor)

sudo nano /etc/sysconfig/network

In that file, change the HOSTNAME value.

GNU nano 2.0.9 File: /etc/sysconfig/network

NETWORKING="yes"
GATEWAYDEV="venet0"
NETWORKING_IPV6="yes"
IPV6_DEFAULTDEV="venet0"
HOSTNAME="example.org"

Save the file.

Now check your hostname by typing hostname in the command line. CentOS should output your current hostname.

Perhaps you might have to restart networking on your CentOS Linux server.

/etc/init.d/network restart

 

Author Bio

Thank you for your interest in my blog! On this miniblog, I write mostly short (technical) blog posts that might interest other people. Read more about me or feel free to contact me.

 

Leave a Reply

Your email address will not be published. Required fields are marked *