Installing a package from the command line on Linux is a simple matter. Combining multiple commands in a single command makes it much easier to complete tasks.
The same goes for security updates.
In this tutorial, we’ll show you how to view available security updates and install them on Ubuntu, LinuxMint, and other debian-based systems.
There are three ways to do this, described in more detail below.
As a Linux administrator, you should keep your system up to date. This will make your system more secure and protect it from unexpected attacks.
If you can’t update all systems because some application dependencies can’t be resolved. At the very least, you should have security patches to make your system 100% compliant.
Method 1: How do I check if there are any security updates available in Debian/Ubuntu?
It is always a good practice to check the list of available security updates before installing a patch. It will provide you with a list of packages that will be updated on your system.
By default, the Unattended – Upgrades package should already be installed on your system. But if this package is not installed on your system, use the following command to install it.
Use the apt-get command or the APT command to install the Unattended -upgrades package.
$sudo apt-get install unattended-upgrades or $sudo apt install unattended-upgradesCopy the code
What is trial run? Most Linux commands have a trial run option that gives the actual output but doesn’t download or install anything.
To do this, you need to add the –dry-run option in the unattended-upgrades command.
$ sudo unattended-upgrade --dry-run -dInitial blacklisted packages: Initial whitelisted packages: Starting unattended upgrades script Allowed origins are: o=Ubuntu,a=bionic, o=Ubuntu,a=bionic-security, o=UbuntuESM,a=bionic Using (^linux-image-[0-9]+\.[0-9\.]+-.*|^linux-headers-[0-9]+\.[0-9\.]+-.*|^linux-image-extra-[0-9]+\.[0-9\.]+-.*|^linux-modul es-[0-9]+\.[0-9\.]+-.*|^linux-modules-extra-[0-9]+\.[0-9\.]+-.*|^linux-signed-image-[0-9]+\.[0-9\.]+-.*|^kfreebsd-image- [0-9]+\.[0-9\.]+-.*|^kfreebsd-headers-[0-9]+\.[0-9\.]+-.*|^gnumach-image-[0-9]+\.[0-9\.]+-.*|^.*-modules-[0-9]+\.[0-9\.] +-.*|^.*-kernel-[0-9]+\.[0-9\.]+-.*|^linux-backports-modules-.*-[0-9]+\.[0-9\.]+-.*|^linux-modules-.*-[0-9]+\.[0-9\.]+-. *|^linux-tools-[0-9]+\.[0-9\.]+-.*|^linux-cloud-tools-[0-9]+\.[0-9\.]+-.*) regexp to find kernel packages Using (^linux-image-4\.15\.0\-51\-generic$|^linux-headers-4\.15\.0\-51\-generic$|^linux-image-extra-4\.15\.0\-51\-generic$|^li nux-modules-4\.15\.0\-51\-generic$|^linux-modules-extra-4\.15\.0\-51\-generic$|^linux-signed-image-4\.15\.0\-51\-generic $|^kfreebsd-image-4\.15\.0\-51\-generic$|^kfreebsd-headers-4\.15\.0\-51\-generic$|^gnumach-image-4\.15\.0\-51\-generic$| ^.*-modules-4\.15\.0\-51\-generic$|^.*-kernel-4\.15\.0\-51\-generic$|^linux-backports-modules-.*-4\.15\.0\-51\-generic$| ^linux-modules-.*-4\.15\.0\-51\-generic$|^linux-tools-4\.15\.0\-51\-generic$|^linux-cloud-tools-4\.15\.0\-51\-generic$) Regexp to find running kernel packages Checking: apt ([]) Adjusting candidate version: apt=1.6.6 Ubuntu0.1 Checking: Apt-utils ([]) apt-utils=1.6.6 Ubuntu0.1 Checking: bash ([]).. Checking: xxd ([, ]) pkgs that look like they should be upgraded: binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-7 dbus dbus-user-session dbus-x11 firefox firefox-locale-en g++ g++-7 gcc gcc-7 gcc-7-base gcc-8-base libasan4 libatomic1 libbinutils libcc1-0 libcilkrts5 libdbus-1-3 libdbus-1-dev libgcc-7-dev libgcc1 libgfortran4 libgomp1 libitm1 liblsan0 libmpx2 libquadmath0 libstdc++-7-dev libstdc++6 libtsan0 libubsan0 vim-common vim-tiny xxdCopy the code
If, on the terminal, the command output above says “No packages found that can be upgraded unattended and No pending auto-removals”, this means that your system is up to date.
How do I install available security updates in Debian/Ubuntu?
If you get any package updates in the command output above, run the following command to install them.
$ sudo unattended-upgrade -d
Copy the code
In addition, you can also use apt-get to install. However, this method is a bit tricky and I would recommend the first option.
Method 2: How to use apt-get to check whether there are security updates available in Debian/Ubuntu?
Run the following command on your Debian/Ubuntu system to view the list of available security updates.
$ sudo apt-get -s dist-upgrade | grep "^Inst" | grep -i securi
Inst libquadmath0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst libitm1 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst gcc-8-base [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libmpx2:amd64 libgcc1:amd64 libtsan0:amd64 liblsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ]
Inst libgcc1 [1:8.2.0-1ubuntu2~18.04] (1:8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libmpx2:amd64 libtsan0:amd64 liblsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ]
Inst libmpx2 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libtsan0:amd64 liblsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ]
Inst liblsan0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libtsan0:amd64 libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ]
Inst libtsan0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libgomp1:amd64 libatomic1:amd64 libcc1-0:amd64 libstdc++6:amd64 ]
Inst libcc1-0 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libgomp1:amd64 libatomic1:amd64 libstdc++6:amd64 ]
Inst libatomic1 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libgomp1:amd64 libstdc++6:amd64 ]
Inst libgomp1 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libstdc++6:amd64 ]
Inst libstdc++6 [8.2.0-1ubuntu2~18.04] (8.3.0-6ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst libdbus-1-dev [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst dbus-user-session [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst dbus-x11 [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst dbus [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst libdbus-1-3 [1.12.2-1ubuntu1] (1.12.2-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst xxd [2:8.0.1453-1ubuntu1] (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst vim-tiny [2:8.0.1453-1ubuntu1] (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst vim-common [2:8.0.1453-1ubuntu1] (2:8.0.1453-1ubuntu1.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [all])
Inst binutils-x86-64-linux-gnu [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [binutils:amd64 ]
Inst binutils-common [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [binutils:amd64 libbinutils:amd64 ]
Inst binutils [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) [libbinutils:amd64 ]
Inst libbinutils [2.30-21ubuntu1~18.04] (2.30-21ubuntu1~18.04.2 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst libasan4 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst libubsan0 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst libcilkrts5 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst g++-7 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst gcc-7 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst libstdc++-7-dev [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst libgcc-7-dev [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst libgfortran4 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst cpp-7 [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64]) []
Inst gcc-7-base [7.3.0-27ubuntu1~18.04] (7.4.0-1ubuntu1~18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst cpp [4:7.3.0-3ubuntu2.1] (4:7.4.0-1ubuntu2.3 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst firefox [67.0.1+build1-0ubuntu0.18.04.1] (67.0.2+build2-0ubuntu0.18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst firefox-locale-en [67.0.1+build1-0ubuntu0.18.04.1] (67.0.2+build2-0ubuntu0.18.04.1 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst gcc [4:7.3.0-3ubuntu2.1] (4:7.4.0-1ubuntu2.3 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Inst g++ [4:7.3.0-3ubuntu2.1] (4:7.4.0-1ubuntu2.3 Ubuntu:18.04/bionic-updates, Ubuntu:18.04/bionic-security [amd64])
Copy the code
How to use apt-get to install available security updates on Debian/Ubuntu systems?
If you find any package updates in the output of the command above. Just run the following command to install them.
$ sudo apt-get -s dist-upgrade | grep "^Inst" | grep -i securi | awk -F "" {'print $2'} | xargs apt-get install
Copy the code
This can also be done using the apt command. However, this method is a little tricky, and I would recommend users to use the first method.
Method 3: How to use apt command in Debian/Ubuntu system to check whether there are available security updates?
Run the following command on a Debian/Ubuntu system to view the list of available security updates.
$ sudo apt list --upgradable | grep -e "-security"Binutils /bionic updates, Bionic security 2.30-21Ubuntu1 ~18.04.2 AMd64 [upgradable from: 2.30-21Ubuntu1 ~18.04] Binutils-common /bionic updates,bionic- Security 2.30-21Ubuntu1 ~18.04.2 amd64 [upgradable from: 2.30-21Ubuntu1 ~18.04] binutils-x86-64-linux-GNU /bionic updates,bionic- Security 2.30-21Ubuntu1 ~18.04.2 amd64 [upgradable From: 2.30-21Ubuntu1 ~18.04] CPP /bionic updates, Bionic security 4:7.4.0-1ubuntu2.3 amd64 [upgradable from: 2.30-21Ubuntu1 ~18.04] CPP /bionic updates, Bionic Security 4:7.4.0-1ubuntu2.3 amd64 [upgradable from: 4.7.3.0-3Ubuntu2.1] Cpp-7 /bionic updates, Bionic - Security 7.4.0-1Ubuntu1 ~18.04.1 amd64 [upgradable from: 7.3.0-27Ubuntu1 ~18.04] DBUS /bionic updates, Bionic - Security 1.12.2-1Ubuntu1.1 AMD64 [upgradable from: 1.12.2-1ubuntu1] dbus-user-session/bionic updates,bionic- Security 1.12.2-1ubuntu1.1 amD64 [upgradable from: 1.12.2-1ubuntu1] dbus-x11/bionic updates, Bionic security 1.12.2-1ubuntu1.1 AMD64 [upgradable from: 1.12.2-1Ubuntu1] Firefox/Bionic updates,bionic- Security 67.0.2+build2-0ubuntu0.18.04.1 amd64 [upgradable from: 67.0.1 + build1-0 ubuntu0. 18.04.1] firefox - the locale - en/bionic - updates, bionic ws-security 67.0.2 + build2-0 ubuntu0. 18.04.1 amd64 [upgradable from: 67.0.1+build1-0ubuntu0.18.04.1] g++/bionic updates,bionic-security 4:7.4.0-1ubuntu2.3 amd64 [upgradable from: Ubuntu 2.0] g++-7/bionic updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] GCC /bionic updates,bionic Security 4:7.4.0-1ubuntu2.3 amd64 [upgradable from: 4.7.3.0-3Ubuntu2.1] gcc-7/bionic updates,bionic security 7.4.0-1Ubuntu1 ~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] gcc-7-base/bionic updates,bionic- Security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] gcc-8-base/bionic updates,bionic- Security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: 8.2.0-1Ubuntu2 ~18.04] libasan4/bionic updates, Bionic - Security 7.4.0-1Ubuntu1 ~18.04.1 amd64 [upgradable from: 7.3.0-27Ubuntu1 ~18.04] Libatomic1 /bionic updates,bionic- Security 8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: 8.2.0-1Ubuntu2 ~18.04] libbinutils/bionic updates,bionic- Security 2.30-21Ubuntu1 ~ 18.04.2amd64 [upgradable from: 2.30-21 Ubuntu1 ~18.04] libcc1-0/bionic updates,bionic- Security 8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: 8.2.0-1Ubuntu2 ~18.04] libcilkrts5/bionic updates,bionic- Security 7.4.0-1Ubuntu1 ~18.04.1 amd64 [upgradable from: 7.3.0-27Ubuntu1 ~18.04] libdbus-3 /bionic updates,bionic- Security 1.12.2-1ubuntu1.1 amd64 [upgradable from: 1.12.2-1ubuntu1] libdbus-1-dev/bionic updates,bionic security 1.12.2-1ubuntu1.1 amd64 [upgradable from: Ubuntu1] libgcc-7-dev/bionic updates,bionic- Security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27Ubuntu1 ~18.04] libgcc1/bionic updates,bionic security 1:8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: 1:8.2.0-1Ubuntu2 ~18.04] libgfortran4/bionic updates,bionic- Security 7.4.0-1Ubuntu1 ~18.04.1 amd64 [upgradable from: Ubuntu1 ~18.04] libgomp1/bionic updates,bionic- Security 8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: Ubuntu2 ~18.04] libitM1 /bionic updates,bionic- Security 8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: Ubuntu 2~18.04] liblsan0/bionic updates,bionic- Security 8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] libmpx2/bionic updates,bionic security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: Ubuntu2 ~18.04] libquadmath0/bionic updates,bionic- Security 8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: Ubuntu 2~18.04] libstdc++-7-dev/bionic updates,bionic-security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27ubuntu1~18.04] libstdc++6/bionic updates,bionic-security 8.3.0-6ubuntu1~18.04.1 amd64 [upgradable from: Ubuntu 2~18.04] libtsan0/bionic updates,bionic- Security 8.3.0-6Ubuntu1 ~18.04.1 amd64 [upgradable from: 8.2.0-1ubuntu2~18.04] libubsan0/bionic updates,bionic- Security 7.4.0-1ubuntu1~18.04.1 amd64 [upgradable from: 7.3.0-27 ubuntu1 ~ 18.04] vim - common/bionic - updates, bionic - updates, bionic ws-security, bionic ws-security 2:8. 0.1453 1 ubuntu1. 1 all [upgradable from: Ubuntu1] viM-tiny /bionic updates, Bionic security 2:8.0.1453-1ubuntu1 amD64 [upgradable from: 2:8.0.1453-1Ubuntu1] XXD /bionic updates,bionic- Security 2:8.0.1453-1ubuntu1 amd64 [upgradable from: 0.1453 1 ubuntu1] 2:8.Copy the code
How to use apt command to install available security updates in Debian/Ubuntu system?
If you find any package updates in the output of the command above. Just run the following command to install them.
$ sudo apt list --upgradable | grep -e "-security" | awk -F "/" '{print $1}' | xargs apt install
Copy the code
Also, the following file will tell you the total number of update packages.
$ sudo cat /var/lib/update-notifier/updates-available
190 packages can be updated.
39 updates are security updates.
Copy the code
Via: www.2daygeek.com/manually-in…
By Magesh Maruthamuthu, Lujun9972
This article is originally compiled by LCTT and released in Linux China