How to Change the Computer Name (Hostname) in Linux Mint 20

This is a beginner’s guide shows how to change the computer name (hostname) in Linux Mint 20.

In Linux world, the computer name is called hostname. It’s a label that is assigned to a device connected to a computer network and that is used to identify the device in various forms of electronic communication.
Hostnames may be simple names consisting of a single word or phrase, or they may be structured.

Change the hostname / computer name for temporary use:

There’s a hostname Linux command allows to change your computer name easily. And it works until reboot.

Open terminal and run command:

sudo hostname NEW_NAME_HERE

In the case, I set the name to ulyana via command sudo hostname ulyana.
You can then check the computer name via hostname command. And the new name will be displayed after @ in new terminal window.

Change the hostname / computer name permanently:

There are a few ways to change the name permanently. It may be different for each desktop environment. For the universal way, you can edit the /etc/hostname configuration file.

  1. Open terminal and run command to edit the file with Linux Mint Cinnamon’s default xed text editor. You may replace xed depends on your DE.
    sudo xed /etc/hostname

    When the file opens, replace the content with your new name and save it.

  2. Also edit the /etc/hosts file and set the new name to avoid networking issue.
    sudo xed /etc/hosts

Finally reboot your system and done.

Merilyn Ne
Hi, I'm Merilyn Ne, a geek who has been working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.