94bc07baf0dbd7a7cf44ff6feb62dade85224e45
By:
dbjerkeli

How do i change hostname?

May 6, 2015 11.3k views
Linux Basics Linux Commands Ubuntu

How do i change the hostname of a running server?

2 comments
3 Answers

Do the following:

  • Step 1. sudo nano /etc/hosts

  • Step 2. change 127.0.1.1 your-current-hostname to 127.0.1.1 your-new-hostname. Then save the file.

  • Step 3. sudo nano /etc/hostsname

  • Step 4. change currently entered hostname in that file and enter your new hostname. Save the file after.

@thefliik - Sorry for that typo.
/etc/hostsname ...should be /etc/hostname.

Have another answer? Share your knowledge.