Set up hostname in Linux or CentOS

A hostname should be useful and memorable. It needs to be 64 characters or less and can only contain alphanumeric characters and dashes. There’s a wide range of opinions out there on what constitutes a good name. Some people like to name systems after famous scientists, or chemical elements, or fantasy references and sometimes administrators in organizations will use some kind of notation that describes a lot of information about the server and even its location, encoded in a way that makes sense to somebody.

in Linux, hostnames are stored in /etc/hostname file. Hostname’s can be alpha numeric i.e.
[a-zA-Z0-9] with a single dash[-] set hostname with hostnamectl command.

hostnamectl --static set-hostname 'your desired name here'
syntax hostnamectl --static set-hostname 9to5host

to know the hostname of a server, type hostname

setup hostname in linux

Leave a comment