How to Change A Server’s Hostname Using the Command Line Interface

Changing the hostname of your server may be necessary for several reasons. For example, if you are utilizing your server as a Mail Server for your domain(s) hosted, then changing the hostname can prevent your emails from going to Spam/Junk. In this article, you can learn how to change your server’s hostname from the command line.

Before You Begin

Review the warnings and notes below, to ensure a smooth transition from one hostname to another.

Change Hostname

  1. SSH into your server using the root user.

  2. Run the following command:

    hostname server.example.com
  3. The prompt should appear, without any output being displayed. You can run the following command to confirm the hostname has been changed:

    hostname

    The output should display similarly to the example below:

    [email protected] ~ $ hostname server.example.com

Congratulations! Now you know how you can change the hostname of your server from the command line.

IC
InMotion Hosting Contributor Content Writer II

InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!

More Articles by InMotion Hosting

Was this article helpful? Join the conversation!