From the Amazon Linux 2023 documentation:
You can change the value of releasever using one of the following methods. These methods are listed in descending system priority. This means that method 1 overrides methods 2 and 3, and method 2 overrides method 3.
- The value in the command line flag, --releasever=latest, if it's used.
- The value that's specified in the override variable file, /etc/dnf/vars/releasever, if it's set.
- The currently installed version of the system-release package.
So releasever can be found with the one-liner:
cat /etc/dnf/vars/releasever || rpm -q system-release
Original answer
Can be found like so:
cat /var/log/dnf.log | grep -i "ddebug releasever:" | rev | cut -f 1 -d " " | rev | tail -n 1
To double check run dnf list system-release. The numbers should be identical.
The packages amazon-linux-repo-s3 or kernel-livepatch-repo-s3 can be used in place of system-release.
How to find Amazon Linux 2023 version? - Stack Overflow
Amazon Linux 2023 new release - never happens.
What's the best way to migrate our EC2 instances from Amazon Linux 1 to Amazon Linux 2?
What are your experiences with patching Amazon Linux 2023?
Videos
From the Amazon Linux 2023 documentation:
You can change the value of releasever using one of the following methods. These methods are listed in descending system priority. This means that method 1 overrides methods 2 and 3, and method 2 overrides method 3.
- The value in the command line flag, --releasever=latest, if it's used.
- The value that's specified in the override variable file, /etc/dnf/vars/releasever, if it's set.
- The currently installed version of the system-release package.
So releasever can be found with the one-liner:
cat /etc/dnf/vars/releasever || rpm -q system-release
Original answer
Can be found like so:
cat /var/log/dnf.log | grep -i "ddebug releasever:" | rev | cut -f 1 -d " " | rev | tail -n 1
To double check run dnf list system-release. The numbers should be identical.
The packages amazon-linux-repo-s3 or kernel-livepatch-repo-s3 can be used in place of system-release.
I see it in eg:
% cat /etc/amazon-linux-release
Amazon Linux release 2023.5.20240805 (Amazon Linux)
% cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.5.20240805"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2028-03-15"
% cat /etc/system-release
Amazon Linux release 2023.5.20240805 (Amazon Linux)
% rpm -q system-release
system-release-2023.5.20240805-0.amzn2023.noarch
% rpm -q system-release --qf "%{VERSION}\n"
2023.5.20240805
% dnf list system-release
Last metadata expiration check: 3:03:53 ago on Fri Nov 7 10:01:06 2025.
Installed Packages
system-release.noarch 2023.5.20240805-0.amzn2023 @amazonlinux
My recipe (/etc/cron.daily/dnf-updates):
#!/bin/bash
readonly V=$(/usr/bin/dnf check-release-update --latest-only --version-only 2>&1)
[ -n "$V" ] && /usr/bin/dnf upgrade --security --assumeyes --releasever=$V
Shortcut:
/usr/bin/dnf upgrade --security --assumeyes --releasever=latest
systemd timers replaced cron in AL2023, so ggrandes' answer did not work for me.
I was able to set up a systemd timer quite easily though.
First create /etc/systemd/system/dnf-security-upgrade.service with the following contents:
[Unit]
Description=Automatic security upgrades for dnf packages
[Service]
Type=oneshot
ExecStart=/usr/bin/dnf upgrade --security --assumeyes --releasever=latest
Then create /etc/systemd/system/dnf-security-upgrade.timer with the following contents:
[Unit]
Description=Timer for automatic security upgrades for dnf packages
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Now, reload the systemd daemon with:
systemctl daemon-reload
Finally, run the following command to start the timer:
systemctl enable --now dnf-security-upgrade.timer