But if you are using the RHEL 7 AMI provided on AWS marketplace the steps will be slightly different.
First login to your EC2 instance. (Check this post to know How to login to AWS EC2 Linux instance.)
Once you login to your EC2 instance execute below command.
sudo hostnamectl set-hostname --static cloudvedas(Here “cloudvedas” is the new hostname.)
If you want to make it persistent across reboot follow further.
Now using vi or vim editor edit the file /etc/cloud/cloud.cfg
sudo vi /etc/cloud/cloud.cfgAt the end of file add the following line and save the file
preserve_hostname: trueFinally reboot the server
sudo rebootOnce the server is up, check the hostname.
ec2-user# hostname
cloudvedas
ec2-user#It should now show you the new hostname.