Skip to content

Linux hostnamectl Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux hostnamectl Guide

Complete beginner-friendly guide to hostnamectl on Linux, covering Arch Linux, CachyOS, and other distributions including hostname management, system identification, and systemd hostname control.


Table of Contents

  1. Understanding hostnamectl
  2. hostnamectl Basics
  3. Setting Hostname
  4. Hostname Information
  5. Troubleshooting

Understanding hostnamectl

What is hostnamectl?

hostnamectl controls system hostname (systemd).

Uses:

  • Set hostname: Change system hostname
  • View hostname: Show hostname information
  • System identification: Identify system
  • Persistent changes: Changes persist across reboots

Why it matters:

  • Modern tool: systemd-based tool
  • Persistent: Changes are permanent
  • System management: Manage system identity

hostnamectl Basics

View Hostname

Basic usage:

# View hostname information
hostnamectl

# Shows hostname details

Current Hostname

Get hostname:

# Current hostname
hostnamectl status

# Shows hostname status

Setting Hostname

Set Hostname

Change hostname:

# Set hostname
sudo hostnamectl set-hostname new-hostname

# Changes hostname permanently

Static Hostname

Set static:

# Set static hostname
sudo hostnamectl set-hostname --static new-hostname

# --static = static hostname

Hostname Information

All Information

Complete info:

# All hostname information
hostnamectl

# Shows:
# - Static hostname
# - Pretty hostname
# - Icon name
# - Chassis
# - Machine ID

Pretty Hostname

Set pretty name:

# Set pretty hostname
sudo hostnamectl set-hostname --pretty "My Computer"

# --pretty = human-readable name

Troubleshooting

hostnamectl Not Found

Check systemd:

# hostnamectl is part of systemd
# Usually pre-installed on systemd systems

# Check systemd
systemctl --version

Summary

This guide covered hostnamectl usage, hostname management, and system identification for Arch Linux, CachyOS, and other distributions.


Next Steps


This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.

Clone this wiki locally