Introduction
The hostname is a unique identifier assigned to every computer or device connected to a network. It facilitates seamless communication between systems within the same network.
Prerequisites
Ensure you have administrative privileges or are logged in as the root user.
Temporarily Changing the Hostname
- Launch terminal
- Verify current hostname:
hostname
- Change hostname temporarily:
sudo hostname new-hostname
Permanently Changing the Hostname
- Edit
/etc/hostname
:
sudo nano /etc/hostname
- Edit
/etc/hosts
:
sudo nano /etc/hosts
- Reboot system:
sudo reboot
Using Hostnamectl Utility
- Change static hostname:
sudo hostnamectl set-hostname new-hostname
- Change transient hostname:
sudo hostnamectl set-hostname --pretty new-hostname
- Verify changes:
hostnamectl
Conclusion
Changing the hostname on AlmaLinux is straightforward using various methods like hostname
command, configuration files, or hostnamectl
utility.