Hostwinds Tutorials

Search results for:


Table of Contents


Display Current Hostname
How To Change Your Hostname In CentOS 7 and Debian 9 and Ubuntu 16.04 and Later

How to Change Your Hostname In Linux

Tags: DNS,  Linux 

Display Current Hostname
How To Change Your Hostname In CentOS 7 and Debian 9 and Ubuntu 16.04 and Later

The hostname is a feature with Linux operating systems that allows the identification of a server. This can be used to easily determine the difference between two servers. Aside from personal identification of the server, the hostname is used with most network processes, and other applications may also rely on this. For example, cPanel / WHM uses the hostname for internal processes.

Display Current Hostname

Step One: Log into your server via SSH.

Step Two: Type in the following command and hit Enter on your keyboard

hostname

How To Change Your Hostname In CentOS 7 and Debian 9 and Ubuntu 16.04 and Later

Step One: Log into your server via SSH as a user with sudo permissions

Step Two: Enter the command as follows, replacing NEWHOSTNAMEHERE with the hostname you want to set for the system.

hostnamectl set-hostname NEWHOSTNAMEHERE

Step Three: If you have any services that rely on the hostname, you may need to restart them to see the change. Alternatively, you can reboot the server to enact the change as well

The NEWHOSTNAMEHERE is typically entered in all lowercase letters

Type in the following command to confirm this change has been made and hit Enter on your keyboard

hostname

If using another version of Linux, you may change the hostname by modifying the file at /etc/hostname to be the hostname that you want to set. This will require a reboot of the server or services that rely on the hostname, including the Network service.

If you should have any questions or would like assistance, please contact us through Live Chat or by submitting a ticket with our Technical Support team.

Written by Hostwinds Team  /  August 31, 2018