Question: How can I find the OS platform or version that my EC2 Linux instance is using?

I want to find the operating system (OS) or version number of my Amazon Elastic Compute Cloud (Amazon EC2) instance. However, I didn't allocate OS-specific tags at launch.

Short descriptionA public Amazon Machine Image (AMI) lists the distribution that it's based on in the Description or Name parameters. When you generate a new AMI that's based on a public AMI, the distribution switches to Custom Linux. In this case, you might not able to view the platform-related information.

ResolutionUsing the Amazon EC2 consoleFrom the Amazon EC2 console, you can use one of the following three methods to check the OS or version number:View the Platform details or AMI ID information.View the instance's console logs or screenshot.View platform information for AWS Systems Manager Managed instances.View the Platform details or AMI ID informationFor the new Amazon EC2 console, complete the following steps:1.    Select the instance.2.    On the Details tab, view OS and version information in the Platform details field. Or, select the AMI ID.For the old Amazon EC2 console, complete the following steps:1.    Select the instance.2.    On the Description tab, view OS and version information from the AMI ID Platform:Platform Details: View the Platform details field for the (inferred) platform that the instance is using.AMI ID: Select the link under the AMI ID field to open the AMI dashboard. Check the Details tab for information about the operating system and version.Note: The AMI dashboard might default to showing AMIs Owned by me. You can change this filter to Public images or Private images, if needed.View the instance's console logs or screenshotFor the new Amazon EC2 console, complete the following steps:1.    Select the instance.2.    Choose Actions, Monitor and troubleshoot, Get system log.3.    Search for a keyword, such as Linux or kernel to look in the log entries.-or-1.    Select the instance.2.    Choose Actions, Monitor and troubleshoot, Get instance screenshot.For the old Amazon EC2 console, complete the following steps:1.    Select the instance.2.    Choose Actions, Instance Settings, Get system log.3.    Search for a keyword, such as Linux or kernel to look in the log entries.-or-1.    Select the instance.2.    Choose Actions, Instance Settings, Get instance screenshot.Note: AWS has limited visibility into the software or OS that's running on an instance. This means that AWS can't provide specific OS-related information. AWS predicts the information in the Platform details field based on the AMI name and description. Because of this, the listed platform isn't always accurate for the preceding two methods. If the console logs are enabled by default, then the logs usually show the OS and version that your instance uses.View platform information for AWS Systems Manager Managed instances1.    Open the Managed instances console.2.    Select the instance. The instance's Platform type, Platform name, and Platform version appear.Note: A managed instance is any machine or instance configured with AWS Systems Manager. To appear on the AWS Systems Manager Managed Instances tab, instances must be running and have the amazon-ssm-agent installed. They must also have the required AWS Identity and Access Management (IAM) permissions assigned to them.For information on prerequisites for using AWS Systems Manager, see Systems Manager prerequisites.Using the AWS Command Line Interface (AWS CLI) on managed instancesYou can use the AWS CLI to view the Linux OS platform and version information for instances that have the ssm-agent installed and configured. Run the following commands to install and use the jquery utility followed by the ssm describe-instances-information command. In the following example command, replace us-east-1 with your AWS Region.Note: If you receive errors when running AWS CLI commands, make sure that you're using the most recent version of the AWS CLI.# sudo yum install -y jq*# aws ssm describe-instance-information --query 'InstanceInformationList[*].[InstanceId,PlatformType,PlatformName]' --output table  --region us-east-1------------------------------------------------------|             DescribeInstanceInformation            |+----------------------+--------+--------------------+|  i-0e446328e4070b25c |  Linux |  SLES              ||  i-09ab5fd0cf37a45da |  Linux |  Amazon Linux AMI  ||  i-0dd6cd6c3210f605e |  Linux |  SLES              ||  i-05dd60329fb29cd74 |  Linux |  Ubuntu            |+----------------------+--------+--------------------+$ aws ssm describe-instance-information --region us-east-1{  "InstanceInformationList": [    {      "IsLatestVersion": false,       "ComputerName": "ip-172-31-39-244.ec2.internal",       "PingStatus": "Online",       "InstanceId": "i-0b89uiydekijihuh",       "IPAddress": "172.31.39.244",       "ResourceType": "EC2Instance",       "AgentVersion": "2.3.978.0",       "PlatformVersion": "15.1",       "PlatformName": "SLES",       "PlatformType": "Linux",       "LastPingDateTime": 1593669078.246    }}Related informationSSM Agent describe-instance-information