Commands to find Linux-package updates


Did you know that you can ask your Linux system to tell you what upgrades are available for the packages installed on it? You might be surprised by how many you’ll see, especially if you’re using the current release and don’t have your system set up for frequent or automatic updates.

Updates play an important role in keeping your Linux systems secure and performing well. Since most packages are updated as fixes or improvements to the code become available, it’s hard to predict how many will show up on any particular day. (Note: Updates should be done when your system is not performing other important tasks.)

Fedora and related systems

To check what updates are currently available for your Fedora or related system, use a command like this:

$ sudo dnf list upgrades
Last metadata expiration check: 2:07:02 ago on Fri 23 Jul 2021 07:36:34 AM EDT.
Available Upgrades
audit.x86_64                            3.0.3-1.fc34                   updates
audit-libs.x86_64                       3.0.3-1.fc34                   updates
curl.x86_64                             7.76.1-7.fc34                  updates
firefox.x86_64                          90.0.1-1.fc34                  updates
libcurl.x86_64                          7.76.1-7.fc34                  updates
libipa_hbac.x86_64                      2.5.2-1.fc34                   updates
libsss_autofs.x86_64                    2.5.2-1.fc34                   updates
libsss_certmap.x86_64                   2.5.2-1.fc34                   updates
libsss_idmap.x86_64                     2.5.2-1.fc34                   updates
libsss_nss_idmap.x86_64                 2.5.2-1.fc34                   updates
libsss_sudo.x86_64                      2.5.2-1.fc34                   updates
podman.x86_64                           3:3.2.3-1.fc34                 updates
podman-plugins.x86_64                   3:3.2.3-1.fc34                 updates
…

On a system which hasn’t been upgraded in a week or so, you might easily see numbers like those shown below where we count all updates and then those that are security updates.

$ sudo dnf list upgrades | wc -l
97
$ sudo dnf list upgrades —security | wc -l
35

Applying the upgrades

To apply the available upgrades, you simply use a command like that shown below. The —refresh option marks the metadata as expired and forces the system to revalidate the cache.

$ sudo dnf upgrade –refresh
Fedora 34 - x86_64                                   36 kB/s |  12 kB     00:00
Fedora 34 openh264 (From Cisco) - x86_64            4.9 kB/s | 989  B     00:00
Fedora Modular 34 - x86_64                           74 kB/s |  12 kB     00:00
Fedora 34 - x86_64 - Updates                         41 kB/s |  10 kB     00:00
Fedora Modular 34 - x86_64 - Updates                 61 kB/s |  11 kB     00:00
Dependencies resolved.
=========================================================================================
 Package              Architecture    Version          Repository        Size
=========================================================================================
Upgrading:
 btrfs-progs          x86_64          5.13-1.fc34      updates          971 k
 gnome-autoar         x86_64          0.3.3-1.fc34     updates           55 k
 python-srpm-macros   noarch          3.9-38.fc34      updates           20 k
 rust-srpm-macros     noarch          18-1.fc34        updates          9.2 k

Transaction Summary
=========================================================================================
Upgrade  4 Packages

Total download size: 1.0 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): python-srpm-macros-3.9-37.fc34_3.9-38.fc34.noarch.drpm 40 kB/s | 9.5 kB 00:00
(2/4): gnome-autoar-0.3.2-1.fc34_0.3.3-1.fc34.x86_64.drpm     47 kB/s |  13 kB 00:00
(3/4): rust-srpm-macros-18-1.fc34.noarch.rpm                 114 kB/s | 9.2 kB 00:00
(4/4): btrfs-progs-5.13-1.fc34.x86_64.rpm                    850 kB/s | 971 kB 00:01
[DRPM 1/2] python-srpm-macros-3.9-37.fc34_3.9-38.fc34.noarch.drpm: done
[DRPM 2/2] gnome-autoar-0.3.2-1.fc34_0.3.3-1.fc34.x86_64.drpm: done
————————————————————————————————————————————-
Total                                                                           667 kB/s | 1.0 MB     00:01
Delta RPMs reduced 1.0 MB of updates to 1.0 MB (5.0% saved)
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                              1/1
  Upgrading        : rust-srpm-macros-18-1.fc34.noarch                            1/8
  Upgrading        : python-srpm-macros-3.9-38.fc34.noarch                        2/8
  Upgrading        : gnome-autoar-0.3.3-1.fc34.x86_64                             3/8
  Upgrading        : btrfs-progs-5.13-1.fc34.x86_64                               4/8
  Cleanup          : rust-srpm-macros-17-2.fc34.noarch                            5/8
  Cleanup          : python-srpm-macros-3.9-37.fc34.noarch                        6/8
  Cleanup          : gnome-autoar-0.3.2-1.fc34.x86_64                             7/8
  Cleanup          : btrfs-progs-5.12.1-1.fc34.x86_64                             8/8
  Running scriptlet: btrfs-progs-5.12.1-1.fc34.x86_64                             8/8
  Verifying        : btrfs-progs-5.13-1.fc34.x86_64                               1/8
  Verifying        : btrfs-progs-5.12.1-1.fc34.x86_64                             2/8
  Verifying        : gnome-autoar-0.3.3-1.fc34.x86_64                             3/8
  Verifying        : gnome-autoar-0.3.2-1.fc34.x86_64                             4/8
  Verifying        : python-srpm-macros-3.9-38.fc34.noarch                        5/8
  Verifying        : python-srpm-macros-3.9-37.fc34.noarch                        6/8
  Verifying        : rust-srpm-macros-18-1.fc34.noarch                            7/8
  Verifying        : rust-srpm-macros-17-2.fc34.noarch                            8/8
Installed products updated.

Upgraded:
  btrfs-progs-5.13-1.fc34.x86_64         gnome-autoar-0.3.3-1.fc34.x86_64
python-srpm-macros-3.9-38.fc34.noarch rust-srpm-macros-18-1.fc34.noarch Complete!

Notice how the update process goes through a number of stages—upgrading, cleanup and verifying—and ends with a listing of the updated packages.

At this point, no more upgrades are available. If you like, you can verify this by repeating the “list upgrades” command above. You should see a line like this with no updates listed.

$ sudo dnf list upgrades
Last metadata expiration check: 0:00:21 ago on Fri 16 Jul 2021 02:24:24 PM EDT.

Ubuntu and related systems

To see what updates are available on Ubuntu, Mint, and related systems, the command to use is apt list –upgradable. It will provide a list of updated packages.

$ apt list —upgradable
Listing... Done
alsa-ucm-conf/focal-updates,focal-updates 1.2.2-1ubuntu0.8 all [upgradable from: 1.2.2-1ubuntu0.7]
apt-utils/focal-updates 2.0.6 amd64 [upgradable from: 2.0.5]
apt/focal-updates 2.0.6 amd64 [upgradable from: 2.0.5]
avahi-autoipd/focal-updates,focal-security 0.7-4ubuntu7.1 amd64 [upgradable from: 0.7-4ubuntu7]
avahi-daemon/focal-updates,focal-security 0.7-4ubuntu7.1 amd64 [upgradable from: 0.7-4ubuntu7]
avahi-utils/focal-updates,focal-security 0.7-4ubuntu7.1 amd64 [upgradable from: 0.7-4ubuntu7]
bluetooth/focal-updates,focal-updates 5.53-0ubuntu3.3 all [upgradable from: 5.53-0ubuntu3]
bluez-cups/focal-updates 5.53-0ubuntu3.3 amd64 [upgradable from: 5.53-0ubuntu3]
bluez-obexd/focal-updates 5.53-0ubuntu3.3 amd64 [upgradable from: 5.53-0ubuntu3]
bluez/focal-updates 5.53-0ubuntu3.3 amd64 [upgradable from: 5.53-0ubuntu3]
dnsmasq-base/focal-updates,focal-security 2.80-1.1ubuntu1.4 amd64 [upgradable from: 2.80-1.1ubuntu1.3]
evolution-data-server-common/focal-updates,focal-updates 3.36.5-0ubuntu1 all [upgradable from: 3.36.4-0ubuntu1]
evolution-data-server/focal-updates 3.36.5-0ubuntu1 amd64 [upgradable from: 3.36.4-0ubuntu1]
...

Note that when you run the command sudo apt update, the final line of output suggests this command:

$ sudo apt update
[sudo] password for shs:
Get:1 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Hit:2 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:3 http://archive.canonical.com/ubuntu focal InRelease
Hit:4 http://ppa.launchpad.net/jtaylor/keepass/ubuntu focal InRelease
Ign:5 http://packages.linuxmint.com ulyssa InRelease
Get:6 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Hit:7 http://packages.linuxmint.com ulyssa Release
Get:8 http://archive.ubuntu.com/ubuntu focal-backports InRelease [101 kB]
Fetched 328 kB in 2s (141 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
16 packages can be upgraded. Run ‘apt list —upgradable’ to see them.   <===

The sudo apt upgrade -y command can then be used to apply all of the available updates to installed packages. Once that process is complete, you can repeat the apt list –upgradable command to show that there are no more available updates.

$ apt list —upgradable
Listing... Done

Wrap-up

Some Linux admins and users update their systems daily or weekly. Others set their systems up for automatic updates. In any case, it’s good to keep your system updated fairly regularly and to have some easy commands on hand to verify that your system is up-to-date.

Join the Network World communities on Facebook and LinkedIn to comment on topics that are top of mind.

Copyright © 2021 IDG Communications, Inc.



Source link