How to change your hostname on Linux the easy way.

Posted: December 19, 2014. At: 8:49 PM. This was 3 years ago. Post ID: 7975
Page permalink.
WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters. These cookies expire two weeks after they are set.

Use the sudo hostnamectl set-hostname HOSTNAME to set a new hostname for your machine. This command does all of the steps in one go and takes the worry out of this task. Just close the terminal after entering this command and reopen it and the new hostname will be visible.

Here I am setting a new hostname of Yog-Sothoth.

sudo hostnamectl set-hostname "Yog-Sothoth"

This will take effect immediately.

Use this command to view the new hostname.

hostnamectl status

Or

hostnamectl status --pretty

This command is available when you are booted using Systemd and may not work on Debian. Read more here: http://wiki.gentoo.org/wiki/Systemd#Hostname.

No comments have been made. Use this form to start the conversation :)

Leave a Reply