You can use hostnamectl or hostname to display or set the hostname of a Debian Linux system. This tutorial explains how to change it permanently.
Follow these steps:
- Connect to your server over SSH:
ssh user@server-name. - Become root using
sudo -sorsu -. - To set the hostname to
server1, run:hostnamectl set-hostname server1. - Edit
/etc/hostsand update the hostname entries:vi /etc/hosts. You can use another text editor if you prefer. - Verify the change by running
hostnamectlagain.
After completing these steps, the system’s hostname should be server1.