+
+
objc
+
vercel
+
+
+
matplotlib
+
bun
+
+
+
+
+
centos
terraform
+
+
elasticsearch
+
mint
+
vite
?
!==
+
+
+
xgboost
->
play
+
+
vue
+
+
+
+
+
+
+
nvim
+
lua
+
dns
+
+
+
next
c++
+
==
supabase
+
node
+
c++
+
strapi
+
sse
elm
::
vercel
php
cargo
+
+
eslint
ansible
mxnet
helm
+
matplotlib
+
ios
+
rider
pinecone
+
+
+
+
λ
+
+
Back to Blog
How to Change Hostname on Ubuntu 22.04
Linux Ubuntu

How to Change Hostname on Ubuntu 22.04

Published Mar 9, 2024

Learn to change your Ubuntu 22.04 system's hostname, a unique identifier, through this guide. Explore temporary and permanent methods like commands and config files.

2 min read
0 views
Table of Contents

Introduction

The hostname is a unique name assigned to a computer or device connected to a network. It serves as an identifier and facilitates communication with other devices on the same network.

Prerequisites

Ensure you have sudo privileges or are logged in as the root user.

Changing the Hostname Temporarily

  1. Check current hostname:
hostname
  1. Change hostname temporarily:
sudo hostname new-hostname

Changing the Hostname Permanently

  1. Edit /etc/hostname:
sudo nano /etc/hostname
  1. Edit /etc/hosts:
sudo nano /etc/hosts
  1. Reboot system:
sudo reboot

Using Hostnamectl Command

  1. Change static hostname:
sudo hostnamectl set-hostname new-hostname
  1. Change transient hostname:
sudo hostnamectl set-hostname --pretty new-hostname

Conclusion

Changing the hostname on Ubuntu 22.04 can be done through multiple methods, providing flexibility for system management.