A computer hostname represents a unique name that gets assigned to a computer in a network in order to uniquely identify that computer in that specific network. A computer hostname can be set to any name you like, but you should keep in mind the following rules:
- hostnames can contain letters (from a to z).
- hostnames can contain digits (from 0 to 9).
- hostnames can contain only the hyphen character
( – )
as a special character. - hostnames can contain the dot special character
( . )
. - hostnames can contain a combination of all three rules but must start and end with a letter or a number.
- hostnames letters are case-insensitive.
- hostnames must contain between 2 and 63 characters long.
- hostnames should be descriptive (to ease identifying the computer purpose, location, geographical area, etc on the network).
In order to display a computer name in CentOS 7/8 and RHEL 7/8 systems via console, issue the following command. The -s
flag displayed the computer short name (hostname only) and the -f
flag displays the computer FQDN in the network (only if the computer is a part of a domain or realm and the FQDN is set).
You can also display a Linux system hostname by inspecting the content of /etc/hostname file using the cat command.
In order to change or set a CentOS 7/8 machine hostname, use the hostnamectl command as shown in the below command excerpt.
In addition to hostname command, you can also use hostnamectl command to display a Linux machine hostname.
0 Comments