How To Change Hostname in Linux
How To Change Hostname in Linux
TUTORIALS menu
A hostname is a name used to identify a device on a network. Usually, it is set as localhost during the
operating system installation.
However, if there are several devices in a network, this might generate duplicates and cause network
conflict. To avoid that, you’re advised to change the hostname of your Linux system.
In this article, we will illustrate three methods to change the hostname on CentOS and other Linux
distributions like Debian, Ubuntu, and Red Hat Enterprise Linux (RHEL).
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 1/10
3/12/24, 4:06 PM How to Change Hostname in Linux
Pro Tip
If you’re just starting, you’ll find all the instructions on how to set up VPS
in our step-by-step guide.
4. Once the installation is complete, type the following command to view the current hostname and hit
Enter:
hostnamectl
6. On the output, the current hostname is listed as the static hostname. To change it permanently,
insert the following command – using your new desired hostname – and hit Enter:
7. The command above does not produce an output. Therefore, to verify the new hostname, run the
command below and press Enter:
hostnamectl
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 2/10
3/12/24, 4:06 PM How to Change Hostname in Linux
3. Scroll down and type the new hostname in the Change Hostname box. Click Save.
TUTORIALS menu
3. The package and list of dependencies will be loaded. Type y and press Enter to start the installation
process.
4. The Complete! line will appear once the nmtui package has been successfully installed.
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 3/10
3/12/24, 4:06 PM How to Change Hostname in Linux
TUTORIALS menu
5. Run this command to check the status of the network manager and press Enter:
6. To start the nmtui service, type the following command and hit Enter:
sudo nmtui
8. On the NetworkManager TUI window, select Set system hostname and press Enter.
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 4/10
3/12/24, 4:06 PM How to Change Hostname in Linux
TUTORIALS menu
vi /etc/hostname
hostinger
3. Next, update the hostname record in the /etc/hosts file so that the system resolves the new
hostname in the network.
# vi /etc/hosts
127.0.0.1 hostinger
At this point, you finished updating the records in the configuration files. However, to apply the changes,
you’ll need to edit the cloud configuration file.
1. Open the cloud configuration file by inserting this command on the terminal and pressing Enter:
preserve_hostname: true
3. Reboot your system and open the terminal. To verify if the hostname was indeed preserved during
the reboot, run the following command and hit Enter:
hostname
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 5/10
3/12/24, 4:06 PM How to Change Hostname in Linux
This will display the new hostname you have set up.
TUTORIALS menu
Important! If the cloud configuration file is not available in your system, you can safely skip
these steps.
This method is useful when you need to complete a minor task that requires temporary changes. The basic
syntax of the command is:
hostname [new_host_name]
1. On the terminal, type the hostname command along with the new hostname and hit Enter.
hostname hostinger
2. Verify if the hostname has been set correctly by inserting the following command and pressing
Enter:
hostname
Conclusion
The system hostname is an essential part of a Linux server as it helps identify your machine within a
network.
Most Linux systems provide tools and commands so users can customize the system hostnames to their
preferences. We shared three methods to change hostnames based on your needs:
Running the hostnamectl command, using nmtui, or editing the hosts file to change the hostname
permanently.
Changing Linux hostname permanently on Hostinger VPS via the hPanel.
Using the hostname [new_host_name] command to change the hostname temporarily and without
rebooting the system.
We hope this article has helped you set up a new hostname in your Linux system. If you have any questions
or suggestions, please share them in the comment section below.
THE AUTHOR
Edward S.
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 6/10
3/12/24, 4:06 PM How to Change Hostname in Linux
Edward is a content editor with years of experience in IT writing, marketing, and Linux
system administration. His goal is to encourage readers to establish an impactful online
TUTORIALS
presence. He also really loves dogs, guitars, and everything related to space.
menu
THE CO-AUTHOR
Noviantika G.
Noviantika is a web development enthusiast with customer obsession at heart. Linux
commands and web hosting are like music to her ears. When she's not writing, Noviantika
likes to snuggle with her cats and brew some coffee.
Related tutorials
08 Mar • VPS
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 7/10
3/12/24, 4:06 PM How to Change Hostname in Linux
TUTORIALS menu
08 Feb • VPS
01 Feb • VPS
6 Best Palworld Server Hosting Providers and Key Features to Look For
With the rising popularity of Palworld, you need reliable and secure game server hosting to elevate your multiplayer experience.
While this open-world...
By Matleena Salminen & Ariffud M.
Excellent
Leave a reply
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 8/10
3/12/24, 4:06 PM How to Change Hostname in Linux
TUTORIALS menu
Comment*
Name*
Email*
By using this form you agree that your personal data would be processed in accordance with our Privacy Policy.
Submit
We accomplish this by continuously developing server technology, giving expert assistance, and ensuring a flawless online website hosting
experience.
And More
HOSTING
Web Hosting
VPS Hosting
CyberPanel Hosting
Cloud Hosting
Business Email
CMS Hosting
Ecommerce Hosting
Website Builder
AI Website Builder
AI Logo Generator
DOMAIN
Domain Transfer
Cheap Domains
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 9/10
3/12/24, 4:06 PM How to Change Hostname in Linux
Domain Extensions
HELP
Tutorials
Knowledge Base
INFORMATION
Migrate to Hostinger
System Status
Affiliate Program
Payment Methods
Rewards
Hostinger Reviews
Pricing
Sitemap
COMPANY
About Hostinger
Our Technology
Roadmap
Customer Care
Blog
LEGAL
Privacy Policy
Terms of Service
https://www.hostinger.in/tutorials/linux-change-hostname#:~:text=Running the hostnamectl command%2C using,and without rebooting the system. 10/10