Go back to .. Jose Maria Perez-Macias

Useful Linux Commands

Get IP Address from Hostname (Debian / Ubuntu)

hostname -I

View or Change Hostname

View current hostname details:

hostnamectl

Set a new hostname:

sudo hostnamectl set-hostname <new_hostname>

After changing the hostname, update /etc/hosts and reboot for changes to fully apply:

sudo nano /etc/hosts
# For example, change:
# 127.0.0.1 localhost oldname
# to:
# 127.0.0.1 localhost newname

sudo reboot