Table of Contents
This tip is about the how to Edit Hostname in Linux. So read this free guide, How to Edit Hostname in Linux step by step. If you have query related to same article you may contact us.
How to Edit Hostname in Linux – Guide
By default, the system hostname is set during the installation process or, when you create a virtual machine, it is dynamically assigned to the instance at startup, but there are situations where you need to change it. This tutorial will walk you through the process of changing the hostname on Linux without having to reboot the system. The instructions should work on any modern Linux distribution that uses systemd. A hostname is a label assigned to a machine that identifies the machine on the network.
Each device on the network must have a unique hostname. The hostname can be a simple string containing alphanumeric characters, dots and dashes. If the device is connected to the Internet (eg web or email server), it is recommended to use a fully qualified domain name (FQDN) as the system hostname. The FQDN consists of two parts, the hostname and the domain name.
Device or system hostnames are used to easily identify a machine within a network in a human-readable format. Not a big surprise, but on a Linux system, the hostname can easily be changed using a simple command like “hostname”.
How to Edit Hostname on Linux
Change hostname through system settings
The easiest way for most people to change the hostname on a Linux machine is to simply go into system settings and click About. Your computer’s current hostname will appear as the first item in the list under Device Name, or similar labels in other distributions.
It’s not immediately obvious, but you can click on the Device Name item and a dialog will pop up allowing you to rename your device. Just type the name you would like to use in the dialog and click Rename. The new hostname will be permanently set and your computer will identify itself to your network with the new name.
Change hostname using Linux terminal
The options that appear in the system settings depend on the desktop environment you are using. The process described above will work with Ubuntu’s default GNOME desktop. If you’ve changed your desktop environment or window manager, however, you may not have the option to change the hostname in your system settings.
If that’s the case, you can change your hostname by opening a terminal window and typing a simple command. The hostnamectl command will allow you to view and change the hostname on most other Linux distributions. Simply open a terminal window and type the following command to view your current hostname along with some related details:
To change the hostname, enter the following command, replacing new-hostname with the name you would like to use:
To verify that the new name has been set, type hostnamectl again and you will see the updated information. Again, the command line method to change the Linux hostname should work on almost all modern Linux distributions, not just Ubuntu.
Final note
I hope you like the guide How to Edit Hostname in Linux. In case if you have any query regards this article you may ask us. Also, please share your love by sharing this article with your friends.