Linux hostnamectl Guide - ryzendew/Linux-Tips-and-Tricks GitHub Wiki
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
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
- hostname Guide - Legacy hostname tool
- System Configuration - System setup
- hostnamectl Documentation:
man hostnamectl
This guide covers Arch Linux, CachyOS, and other Linux distributions. For distribution-specific details, refer to your distribution's documentation.