How to Change A Server’s Hostname Using the Command Line Interface Updated on November 19, 2021 by InMotion Hosting Contributor 1 Minutes, 47 Seconds to Read 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. 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 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 to request an update to your PTR. Change Hostname IMPORTANT: Root access on a VPS/Dedicated Server hosting is required to follow the steps below. SSH into your server using the root user. Run the following command: hostname server.example.com 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. Share this Article IC InMotion Hosting Contributor Content Writer 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 Related Articles Understanding Linux Operating Systems How to Install Python 3.9 on CentOS 7 Speed Up grep Searches with LC_ALL=C How To Install RubyGems On Linux unrar and rar Commands 5 Ways to Find a File in Linux Setting Your PHP Settings in Command Line How to Check the Memory Usage on Linux How to Send Files to the Trash Can in Linux with Gio Trash How to Merge PDF Files in the Linux Terminal