[英]Find if AWS instance is running Amazon Linux 1 or 2?
In AWS I need to add amazon linux instance to domain based on this article .在 AWS 中,我需要根据这篇文章将 amazon linux 实例添加到域中。 However how do i know which Amazon Linux version the instance is using.但是我怎么知道实例使用的是哪个 Amazon Linux 版本。 I do not have access to AWS console.我无权访问 AWS 控制台。 But i do have access to actual instance.但我确实可以访问实际实例。 What linux command i should be using.我应该使用什么 linux 命令。
I use uname -srm
command which returns Linux 4.4.0-1057-aws x86_64
我使用uname -srm
命令返回Linux 4.4.0-1057-aws x86_64
Not sure if this is Amazon Linux 1 or Amazon Linux 2不确定这是 Amazon Linux 1 还是 Amazon Linux 2
You can use /etc/os-release
file to get the info about Amazon Linux Version, the machine is running.您可以使用/etc/os-release
文件获取有关 Amazon Linux 版本的信息,机器正在运行。
In case of Amazon 1如果是亚马逊 1
[ec2-user@ip-xxx- ~]$ cat /etc/os-release NAME="Amazon Linux AMI" VERSION="2018.03" ID="amzn" ID_LIKE="rhel fedora" VERSION_ID="2018.03" PRETTY_NAME="Amazon Linux AMI 2018.03" ANSI_COLOR="0;33" CPE_NAME="cpe:/o:amazon:linux:2018.03:ga" HOME_URL="http://aws.amazon.com/amazon-linux-ami/"
In case of Amazon 2如果是亚马逊 2
[ec2-user@xxxx ~]$ cat /etc/system-release Amazon Linux release 2.0 (2017.12) LTS Release Candidate [ec2-user@fresh-amazon-host ~]$ cat /etc/os-release NAME="Amazon Linux" VERSION="2.0 (2017.12)" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2.0" PRETTY_NAME="Amazon Linux 2.0 (2017.12) LTS Release Candidate" ANSI_COLOR="0;33" CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2.0" HOME_URL="https://amazonlinux.com/"
As you can clearly see the two different versions, mentioned as Amazon Linux and Amazon Linux 2.0正如您可以清楚地看到两个不同的版本,称为 Amazon Linux 和 Amazon Linux 2.0
$ cat /etc/system-release
or要么
$ cat /etc/issue
or要么
$ uname -a
and head for https://aws.amazon.com/amazon-linux-ami/前往https://aws.amazon.com/amazon-linux-ami/
You can use the following command:您可以使用以下命令:
rpm -E %{rhel}
For Operating System: Amazon Linux 2适用操作系统:Amazon Linux 2
The answer is: 7
Here's a one-liner.这是一个单线。
awk -F '[="]*' '/^PRETTY_NAME/ { print $2 }' < /etc/os-release
It prints out:它打印出来:
Amazon Linux 2
Well, the announcement in: https://aws.amazon.com/about-aws/whats-new/2017/12/introducing-amazon-linux-2 states that it uses a 4.9 kernel.嗯,公告在: https ://aws.amazon.com/about-aws/whats-new/2017/12/introducing-amazon-linux-2 声明它使用 4.9 内核。 Yours is older, so I would say it is Linux 1.你的比较旧,所以我会说它是 Linux 1。
Still, the following call from the terminal should give you the AMI ID and you could do a search on that(see docs at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html ):不过,来自终端的以下调用应该会为您提供 AMI ID,您可以对其进行搜索(请参阅https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata 上的文档。网页格式):
curl http://169.254.169.254/latest/meta-data/ami-id
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.