Home

How to Change the Hostname on Ubuntu Server

Got an ugly command prompt? Learn how to change the name of your computer.

To change the hostname on an Ubuntu server, you need to edit two files:

  1. /etc/hostname
  2. /etc/hosts

You'll need root permissions to edit. So, for #1:

$ sudo vim /etc/hostname

Note: Replace vim with the editor of your choice.

This file should just contain your hostname, so you can change the old name to the new name, then save and quit.

Next file:

$ sudo vim /etc/hosts

You probably see something like this near the top of the file:

/etc/hosts

127.0.0.1       localhost
127.0.1.1 old_server_name

# ...

Here change what you find at old_server_name to your new hostname.

And reboot.

$ sudo reboot

Let's Connect

Keep Reading

Accessing a Notion Database Using the API

Set up a Notion API integration, make a database connection, and write a Node.js script that retrieves an ID value for a Notion database from the API.

Apr 01, 2023

Never Lose Copied Text Again!

If you’re constantly copying and pasting and losing what is on your clipboard, here’s the perfect solution!

Dec 13, 2022

Convert PDF to Image with Dragonfly and Rails

Converting a PDF to an image using Rails and Dragonfly is actually quite simple. Check it out.

Jan 06, 2015