Get aws ec2 instance id from shell/bash

cat /sys/devices/virtual/dmi/id/board_asset_tag

#short hostname
hname=$(cat /sys/devices/virtual/dmi/id/board_asset_tag | awk '{print substr($0,5,15)}')
hostnamectl set-hostname $hname

Published by

Leave a Reply

Your email address will not be published. Required fields are marked *