fbpx

How to change hostname on Amazon Linux 2 without reboot

· >
change hostname on Amazon Linux 2 without reboot

How to Change The Hostname On Amazon Linux 2 Without Rebooting?

Changing the hostname on Amazon Linux is one of the most important tasks that need to be performed in the system setup. In this tutorial, let us look at how to change the hostname without rebooting the system.

Prerequisites

Before you begin setting up the hostname, make sure you are logged in with a non-root user with sudo privileges.

Steps To Change Hostname On Amazon Linux 2

Follow these steps to change the hostname without rebooting the system:

  • Open a terminal window on your system.
  • Check the current hostname using the hostname -f command.
  • Use the hostnamectl command to change the static hostname.
    • hostnamectl set-hostname NEW_HOSTNAME
  • Edit the /etc/hosts file to replace the existing hostname with the new hostname.
  • Run the hostname -f command to verify the hostname change.
  • Run the systemctl restart systemd-hostnamed command to commit the changes written to the disk without rebooting the system.

Articles related to changing hostname in linux

Conclusion

Changing the hostname on Amazon Linux 2 is a simple task, which can be done using the hostnamectl command. You can also commit the changes without rebooting the system by running the systemctl command. We hope this tutorial was helpful to you.

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments