Check for pending upgrades on Ubuntu.

Update package index.

$ sudo apt update
Hit:1 http://deb.debian.org/debian bullseye InRelease
Get:2 http://security.debian.org/debian-security bullseye-security InRelease [48.4 kB]           
Get:3 http://archive.raspberrypi.org/debian bullseye InRelease [23.6 kB]                                                     
Get:4 http://deb.debian.org/debian bullseye-updates InRelease [44.1 kB]                                                      
Get:5 http://security.debian.org/debian-security bullseye-security/main armhf Packages [218 kB]                              
Get:6 http://security.debian.org/debian-security bullseye-security/main arm64 Packages [218 kB]
Get:7 http://security.debian.org/debian-security bullseye-security/main Translation-en [145 kB]
Get:8 https://pkgs.tailscale.com/stable/debian bullseye InRelease                    
Get:9 http://archive.raspberrypi.org/debian bullseye/main arm64 Packages [302 kB]    
Get:10 https://pkgs.tailscale.com/stable/debian bullseye/main armhf Packages [7,110 B]
Get:11 http://archive.raspberrypi.org/debian bullseye/main armhf Packages [311 kB]
Get:12 https://pkgs.tailscale.com/stable/debian bullseye/main all Packages [354 B]
Get:13 https://pkgs.tailscale.com/stable/debian bullseye/main arm64 Packages [7,105 B]
Fetched 1,332 kB in 2s (760 kB/s)
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
21 packages can be upgraded. Run 'apt list --upgradable' to see them.

I will use apt-check utility provided by the update-notifier-common package.

$ dpkg-query -S /usr/lib/update-notifier/apt-check       
update-notifier-common: /usr/lib/update-notifier/apt-check
$ apt info update-notifier-common
Package: update-notifier-common
Version: 3.192.54.5
Priority: optional
Section: gnome
Source: update-notifier
Origin: Ubuntu
Maintainer: Michael Vogt <michael.vogt@ubuntu.com>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 1 503 kB
Pre-Depends: dpkg (>= 1.15.7.2), apt (>= 1.1~)
Depends: python3:any, python3-apt, python3-dbus, python3-debian, python3-debconf | debconf (<< 1.5.64~), python3-distro-info, lsb-release, patch, update-manager-core (>= 1:17.04.2)
Recommends: libpam-modules (>= 1.0.1-9ubuntu3)
Suggests: policykit-1
Replaces: update-notifier (<< 0.75.1)
Task: ubuntu-desktop-minimal, ubuntu-desktop, cloud-image, server, ubuntu-server-raspi, xubuntu-desktop, lubuntu-desktop, ubuntukylin-desktop, ubuntu-mate-core, ubuntu-mate-desktop, ubuntu-budgie-desktop, ubuntu-budgie-desktop-raspi
Phased-Update-Percentage: 90
Download-Size: 185 kB
APT-Sources: http://pl.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
Description: Files shared between update-notifier and other packages
 Apt setup files and reboot notification scripts shared between
 update-notifier and other packages, notably for server use cases.

Display usage information.

$ /usr/lib/update-notifier/apt-check --help
Usage: apt-check [options]

Options:
  -h, --help            show this help message and exit
  -p, --package-names   Show the packages that are going to be
                        installed/upgraded
  --human-readable      Show human readable output on stdout
  --security-updates-unattended
                        Return the time in days when security updates are
                        installed unattended (0 means disabled)

Display heman readable summary.

$ /usr/lib/update-notifier/apt-check --human-readable
9 updates can be applied immediately.
4 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

List upgradeable packages.

$ /usr/lib/update-notifier/apt-check --package-names
gnome-initial-setup
google-chrome-stable
git
alsa-ucm-conf
gitk
linux-firmware
haproxy
ubuntu-advantage-tools
git-man

Display the number of updates that can be applied immediately and the number of included standard security updates using machine friendly format.

$ /usr/lib/update-notifier/apt-check
9;4
ko-fi