MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
November
Sun Mon Tue Wed Thu Fri Sat
           
20 21 22
23 24 25 26 27 28 29
30            
2025
Months
NovDec


Thu, Nov 20, 2025 12:03 pm

Changing the name of a Ubuntu Linux system from the command line

To change the name of a system running the Ubuntu Linux operating system from a command-line interface (CLI), i.e., a terminal window, you can take the following steps:
  1. In the terminal window enter the command sudo hostnamectl set-hostname newname where newname is the new name you wish to assign to the system. E.g.:
    jim@Firefly:~$ sudo hostnamectl set-hostname Smaug
    [sudo: authenticate] Password: 
    jim@Firefly:~$

    That will change the host name stored in /etc/hostname.

  2. Then edit the /etc/hosts file, replacing the old host name there with the new one. E.g., if I had the following lines in the hosts file, I would modify the second line containing the old host name.
    127.0.0.1 localhost
    127.0.1.1 Firefly
    

    The 127.0.0.1 in the above lines is the localhost IP address, a loopback address that can be used when troubleshooting network issues. Ubuntu also adds a 127.0.1.1 address in /etc/hosts with the name you have assigned to the system. The name should match the one in /etc/hostname, so change the name for the 127.0.1.1 address to the new name you wish to use.

References:

  1. What is difference between localhost address 127.0.0.1 and 127.0.1.1
    Updated: April 2, 2021
    Ask Ubuntu

[/os/unix/linux/ubuntu] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo