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

Deleted 3 Apps Thanks to Raycast

Raycast has boosted my productivity while also covering the offerings of three applications I was using.

Dec 09, 2022

Making Videos with Code is Cool, but is it Productive?

There are more and more tools out there that let you build things (that aren’t websites) with code. Like Remotion for making videos with React. It’s super cool. But should you use it?

May 22, 2022

Compile ES6 Code with Gulp and Babel, Part 2

In the second of five parts on compiling multiple ES6 files into a minified bundle, you will learn how to concatenate multiple files into a single file.

Dec 18, 2018