How to change a hostname in Linux |

How to change a hostname in Linux

Use the hostnamectl command to change your hostname on a Linux computer.

Person using a laptop

Subscribe now

Get the highlights in your inbox every week.

To change your hostname on a Linux computer, use the hostnamectl command.

For example, to change your computer's hostname to myhostname:

$ sudo hostnamectl --static \
--transient \
--pretty \

What is a hostname? 

Computers have network addresses, but they're usually difficult for humans to remember. Hostnames are labels intended to help humans refer to a specific computer. Instead of navigating to, for instance, you navigate to www . example . com.

Read Alan Formy-Duval's article What's in a hostname? for more information about hostnames.

Tips and gears turning

Learn how networks work and some tricks to optimize network performance with open source.

About the author

Seth Kenlon
Seth Kenlon - Seth Kenlon is a UNIX geek, free culture advocate, independent multimedia artist, and D&D nerd. He has worked in the film and computing industry, often at the same time. He is one of the maintainers of the Slackware-based multimedia production project Slackermedia.