---
title: "How to Change A Server&#8217;s Hostname Using the Command Line Interface"
description: "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..."
url: https://www.inmotionhosting.com/support/server/linux/how-to-change-a-server-s-hostname-using-the-command-line-interface/
date: 2018-03-07
modified: 2021-11-19
author: "InMotion Hosting Contributor"
categories: ["Linux"]
type: post
lang: en
---

# How to Change A Server&#8217;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](/support/email/configuring-your-vps-dedicated-server-as-a-mail-server/). 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.

**NOTE: **Your hostname will be viewable in every email header, so choose wisely.
**NOTE: **Your hostname must be in the format of a subdomain (server.example.com).
**NOTE: **Avoid choosing a subdomain that you are currently (or plan on) hosting in a cPanel account.
**NOTE: **Changing your hostname will require an update of the SSL Certificate for services (such as cPanel/Webmail, FTP, Dovecot (SMTP/IMAP), etc.).
**NOTE: **Changing your hostname will require an update to all references of the previous hostname in your connection(s) to the server (such as IMAP/SMTP/POP, FTP, and remote MySQL clients) with the new hostname.
**IMPORTANT: **The new hostname will remain as assigned until your server is restarted. In order for this change to persist through restarts, our Systems Administrator will need to update your hostname. Once you have changed the hostname in WHM, you can contact our [Live Support](/support/amp/how-to-get-great-technical-support/) to request an update to your hostname.
**IMPORTANT: **Our Systems Administrator will need to update the **IP address Pointer (PTR) record** on your behalf. Once you have changed the hostname in WHM, you can [submit a ticket](/support/amp/how-to-get-great-technical-support/#submit-ticket) to request an update to your PTR.

## Change Hostname

**IMPORTANT: **[Root access](/support/amp/obtain-root-access/) on a [VPS](https://www.inmotionhosting.com/vps-hosting)/[Dedicated Server](https://www.inmotionhosting.com/dedicated-servers) hosting is required to follow the steps below.

1. [SSH](/support/server/ssh/how-to-login-ssh/) into your server using the **root** user.
2. Run the following command: hostname server.example.com

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