In Linux-based operating systems, setting or changing the system’s hostname is a straightforward task. With just a few commands, you can customize your server’s identity as you wish. This guide will provide step-by-step instructions on how to change the hostname on a CentOS operating system.
Step 1: Check the Current Hostname
First, use the following command to check your current hostname:
hostnamectl
This command will list the current hostname and other related information on the system.
Step 2: Set the New Hostname
To set a new hostname, use the command below. Replace "server.domain.com" with your preferred hostname:
hostnamectl set-hostname server.domain.com
This command sets the hostname to "server.domain.com." You can customize it as you like.
Step 3: Verify the Changes
To confirm that the new hostname is set correctly and there are no errors, run:
hostnamectl
This command will display the new hostname along with other system information. If your new hostname is shown correctly, the process is complete.
You have now successfully changed the hostname on your CentOS operating system! You can identify and manage your server with the new hostname.