How to Set or Change Hostname in CentOS 7 - 21102019

Breaking

Post Top Ad

Responsive Ads Here

Post Top Ad

Responsive Ads Here

Monday, July 16, 2018

How to Set or Change Hostname in CentOS 7

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 special character.
  • hostnames can contains 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 contains 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 and RHEL 7 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).
# hostname
# hostname -s
# hostname -f
Check Hostname in CentOS 7
Check Hostname in CentOS 7
You can also display a Linux system hostname by inspecting the content of /etc/hostname file using the cat command.
# cat /etc/hostname
Display CentOS 7 Hostname
Display CentOS 7 Hostname
In order to change or set a CentOS 7 machine hostname, use the hostnamectl command as shown in the below command excerpt.
# hostnamectl set-hostname your-new-hostname

No comments:

Post a Comment

Post Top Ad

Responsive Ads Here