I'm trying to change the hostname on my fresh CentOS 6.5 image (VPS) via SSH. The sources I've found all say the hostname can be permanently changed in /etc/sysconfig/network and /etc/hosts, and that the current hostname can be checked using the hostname command. The problem, however, is that the hostname command doesn't return anything shown in either of the two aforementioned files. For clarity, in the following commands the following information has been substituted: username (obvious), curHN is what is currently reported after the @ sign in my SSH prompt, provider.com is my VPS provider's website.

What would be the correct way of changing the hostname on this setup?

[username@curHN ~]$ hostname

[username@curHN ~]$ cat /etc/sysconfig/network

[username@curHN ~]$ cat /etc/hosts   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

2 Answers 2


You've mentioned all of the pieces to change it. Use the hostname command with the new hostname as an argument (Your current shell won't reflect the change; log out and back in again), set the hostname parameter in /etc/sysconfig/network for reboot persistence, and then make sure that /etc/hosts has a line to match the IP to the new hostname for local hostname resolution.



Edit simple /etc/sysconfig/network and put hostname fqdn then edit /etc/hostname and put hostname fqdn then edit /etc/hosts. For example,your hostname fqdn is linux.feel.good and ip is so /etc/sysconfig/network


/etc/hostname (can be also /etc/HOSTNAME)


and /etc/hosts  linux.feel.good  linux

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .