Ubuntu Change Hostname or Computer name
As we all know that Ubuntu is a free and secure OS to use but, we can see many people complain about its user-friendliness because most of the settings related to Ubuntu should be done only by the terminal which contains many commands to remember, The main problem among all those problems is How to Change Hostname or in other words we can say it as Computer name, So in this post we can discuss about the Ubuntu Change Hostname or Computer name.
We can change the hostname of your computer temporarily or permanently But In the case of temporary the name, you have changed works until the next reboot.
Change Ubuntu Hostname Temporarily:
Method-1: Change in Settings:
Just Click on Alt+F2 to open Ubuntu dash which is available in the top left most corner and search for System details then tap enter or you can even find your System details in your Settings Tab.
After opening the System details you can find a new window with all your system configurations along with your Device name you can simply change the name of your device right there, and that’s it your device will show the new name until the next reboot, You can check your present hostname in the terminal.
NOTE: To Check your present Hostname just open your terminal and type the below command.
Method-2: Change Hostname via Terminal:
To Change your System name using the Terminal just Open Terminal>And execute the following command.
sudo hostname Your_Desired_Name_HERE
For example, if you want to change the name as Techlame just type “sudo hostname Techlame”. But remember this is temporary the name will be reverted back to Default if you restart your System.
Note: The changes may not be visible in the same window but to check whether the hostname is changed or not you can check in new terminal window.
Change Ubuntu Hostname Permanently:
To Change System hostname permanently we need to change hosts and hostname files which is available under “/etc/hosts” and “/etc/hostname”
First, we need to install gksu to get access to the files and to make changes. To install gksu into you system open your terminal and type the following command.
sudo apt install gksu
By this, you can get access to change the host files. Now open your terminal and execute the following commands.
gksudo gedit /etc/hostname gksudo gedit /etc/hosts
If you are using Ubuntu server then don’t use above lines just use the below commands.
sudo nano /etc/hostname sudo nano /etc/hosts
By executing the first command you can observe a new pop up file which contains your present hostname just type your desired hostname and to save the file type CTRL+X then followed by “Y” then Enter.
To save the file the path could be something like this CTRL+X, “Y” and Tap Enter.
And later by executing the second command you can observe a new pop up file which specifies the details about your Hosts. Now in the second line, you can observe the present hostname which you need to change right there and type your new hostname and save the file in the process which is explained above in the Hosts file.
Note: Remember that the hostname typed in the hosts file and hostnames file should be same.
And that’s it the hostname has been changed for your system but the changes will not be visible now for that you need to restart your computer after switching on your new hostname will be visible on your Device.
If you are the person like me and don’t want to restart the system then you can execute the following command to refresh the host files.
systemctl restart systemd-logind.service
Ubuntu Change Hostname:
By the above process, you can change the Hostname easily, By reading this article we are assuming that you have got some idea about Ubuntu Change Hostname or Computer name.You can share your views and thoughts in the comment section below.
Visit Also: Command Prompt Tricks and Hacks for Windows 10