In this article you will find more about hostname commands in linux systems. you will learn how to find hostname or how change host name in linux systems.there is some ways to change hostname in centos(linux) systems.
Find Hostname in linux
you can use command below in ssh to find hostname in centos or linux systems
Change Hostname in linux
To chane your linux server host name you can use this way.
replace server.sampledomain.com with your hostname
Permanent hostname change on Debian systems
Debian based systems use the file /etc/hostname to read the hostname of the system at boot time and set it up using the init script /etc/init.d/hostname.sh
So on a Debian based system we can edit the file /etc/hostname and change the name of the system and then run:
to make the change active. The hostname saved in this file (/etc/hostname) will be preserved on system reboot (and will be set using the same script we used hostname.sh).
Permanent hostname change on RedHat based systems
RedHat based system use the file /etc/sysconfig/network to read the saved hostname at system boot.
the output will be like this you can edit hostname field and save and exit file with CTRL+X.
the you should reboot your server for changes take effect.