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