How to change Hostname in linux Server ?

Open the terminal:Log in to your Linux server either directly or through SSH

Check EC2 Instance Machine Details:

hostnamectl

Check the Current Hostname: You can check the current hostname using the hostname command

hostname

Method - 1: Change the Hostname

 hostnamectl set-hostname awsserver

Method - 2 :Change hostname:

cat /etc/hostname

Update the /etc/hostname File:

vi /etc/hostname

Restart the System:

To apply the new hostname, you'll need to restart the server:

sudo reboot