Skip to content

Linux hostname Guide

Mattscreative edited this page Dec 5, 2025 · 2 revisions

Linux hostname Guide

Complete beginner-friendly guide to hostname on Linux, covering Arch Linux, CachyOS, and other distributions including setting hostname, viewing hostname, and system identification.


Table of Contents

  1. Understanding hostname
  2. hostname Basics
  3. Setting Hostname
  4. Persistent Hostname
  5. Troubleshooting

Understanding hostname

What is hostname?

hostname shows or sets system hostname.

Uses:

  • View hostname: Show current hostname
  • Set hostname: Change system hostname
  • System identification: Identify system
  • Network identification: Identify on network

Why it matters:

  • System identity: System identification
  • Network: Network identification
  • Services: Some services use hostname

hostname Basics

View Hostname

Basic usage:

# View hostname
hostname

# Shows current hostname

FQDN

Full hostname:

# Full qualified domain name
hostname -f

# -f = FQDN

Setting Hostname

Set Hostname

Change hostname:

# Set hostname
sudo hostname new-hostname

# Changes hostname (temporary)

Persistent Hostname

Make permanent:

# Edit hostname file
sudo vim /etc/hostname

# Or use hostnamectl
sudo hostnamectl set-hostname new-hostname

Persistent Hostname

Using hostnamectl

Modern method:

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

# Persists across reboots

Manual Method

Edit file:

# Edit /etc/hostname
echo "new-hostname" | sudo tee /etc/hostname

# Also update /etc/hosts

Troubleshooting

hostname Not Found

Check installation:

# Check hostname
which hostname

# Usually in inetutils
# Install if missing
sudo pacman -S inetutils

Summary

This guide covered hostname 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