How to get the number of available updates on an Ubuntu system as a normal user

The number of pending security updates can be found using:

/usr/lib/update-notifier/apt-check 2>&1 | cut -d ';' -f 1

and the number of pending regular updates can be found using:

/usr/lib/update-notifier/apt-check 2>&1 | cut -d ';' -f 2

https://superuser.com/questions/199869/check-number-of-pending-security-updates-in-ubuntu


using sudo is your answer, you will likely need to add the user you want to run the script at to the sudoers file and probably with the nopasswd flag so it doesnt prompt for your password everytime the script runs, for more info about sudo, try taking a look here: https://help.ubuntu.com/community/Sudoers


Ubuntu has many packaged nagios plugins, including the handy check_apt, a custom C program. It's slightly better than update-notifier in that its dependencies are smaller; if you're interested in monitoring servers you've probably already installed it! The output looks like this (if you don't like it it seems trivial to fork the program to print what you need):

APT OK: 0 packages available for upgrade (0 critical updates).

If nagios alerting isn't your preference, you can do what I do and install apticron, which will send you email notifications about available updates on a system.