0

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
curHN.provider.com

[username@curHN ~]$ cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=localhost.localdomain

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

2 Answers 2

0

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.

https://serverfault.com/questions/369415/configure-domain-name-in-centos

0

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 1.2.4.5 so /etc/sysconfig/network

HOSTNAME=linux.feel.good 

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

linux.feel.good 

and /etc/hosts

1.2.4.5  linux.feel.good  linux

You must log in to answer this question.

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