Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on some system admin automation using fabric and I'd like to be able to monitor the number of packages that need upgrading on a given machine. This is the same information that I can see when I first log in to a machine, i.e. this part:

35 packages can be updated.
22 updates are security updates.

Is there a command that I can run (preferably without sudo) that gives just that information?

I've looked at the apt-python bindings, but they seem to have a high learning curve and they also appear to be changed around a lot -- I'd like something that will work at least as far back as lucid without needing to do different things on different Ubuntu versions.

share|improve this question
up vote 21 down vote accepted

To obtain that output, you can use the command

sudo /usr/lib/update-notifier/update-motd-updates-available

or, if you don't want to use sudo,

cat /var/lib/update-notifier/updates-available


The login application shows the output found in the file /etc/motd, that is a symbolic link to /var/run/motd.

This last file is updated by the mounted-varrun service (see /etc/init/mounted-varrun.conf) invoking all scripts in /etc/update-motd.d/, and in particular


that in turn calls the script


this script executes various actions, and at last writes the output to the text file



Regarding the reboot part of the question, run this command


it will give no output if reboot is not required.

share|improve this answer
dead interesting..thanks – andybleaden Jun 22 '11 at 9:03
I'm just checking on a machine running 11.04 and byobu shows 44 updates required. cating the file you suggest is blank, and the script you first point to doesn't exist on this machine -- is it in some package that needs to be installed? I have /usr/lib/update-manager, but no update-notifier directory. – KayEss Jun 22 '11 at 11:42
Tested on 11.04 desktop. Those files belong to update-notifier-common that was installed automatically on a fresh installation (not upgrade from 10.10). – enzotib Jun 22 '11 at 12:17
I've looked at some more machines. For those that have /var/lib/update-notifier/apt-check this looks like it returns the two numbers, i.e. 43;24 (43 updates, 24 are security ones), but even that doesn't appear on all my machines. I suppose that this file might have moved between packages in different versions. – KayEss Jun 23 '11 at 2:12

Why can't you just run this?

/usr/lib/update-notifier/apt-check --human-readable

That's what /usr/lib/update-notifier/update-motd-updates-available does to collect the information, at least in the version of Ubuntu I'm using (12.10).

share|improve this answer
Just checked on Lucid and it works there too – KayEss Apr 3 '13 at 16:49
It writes its output to stderr. Who would do that? – KayEss Apr 26 '13 at 3:57
Prefer this approach since it completely side steps the whole update-motd package and its thinking. Thanks for just giving the direct command. – jefflunt Aug 14 '13 at 21:51

Well you can use

sudo apt-get update

it won't give you the list... or you can use system->administration->update manager but it is graphical :P

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.