Linux - change the hostname in the CLI
- Edit
/etc/sysconfig/network
and change/add HOSTNAME variable like soHOSTNAME=server1.domain.com
After restart it should have server1. - Edit /etc/hosts and add
server1
andserver1.domain.com
to 127.0.0.1 line, so it will look like:127.0.0.1 localhost.localdomain localhost server1 server1.domain.com
More about network file you can read here: https://docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/ch-The_sysconfig_Directory.html#s2-sysconfig-network
you can type "hostname HOSTNAME" where HOSTNAME is the new name you want. The next time you log in / connect via ssh, that's what you'll see.