List available updates but do not install them

  • I want my cron-run reporting script to notify me in case there are updates for my packages. Is the a way to make apt-get give me the list of available updates but don't do anything more?

  • apt

    For modern versions of apt there is a specific switch for this:

    apt list --upgradeable


    For the old apt-get command the -u switch shows a list of packages that are available for upgrade:

    # apt-get -u upgrade --assume-no

    From the apt-get man page:

     Show upgraded packages; Print out a list of all packages that are to be upgraded. Configuration Item: APT::Get::Show-Upgraded.
    --assume-no  Automatic "no" to all prompts. <== To prevent it from starting to install

    I was hoping this could be done without root

    If you type "Y" and press Enter, this command _will_ install updates. I would definitely recommend to add "-s", otherwise this answer is misleading

    This is a *very* wrong answer because (without additional options) the command waits for input and if the user enters the wrong input, the package are installed, *which modifies the system* which is not what the OP wants (just happened on my system)

    And btw: `-u` is a default option of `apt-get`

    @ThorSummoner '-s' will do what you want & works without root

    @nevelis Ah and your comment is reflected in this answer too, perfect!

    I prefer the first option because does not require sudo. The second does.

    `apt list --upgradable` is not an equivalent of `apt-get -u upgrade --assume-no` .. the former will only respect UPgrades, no downgrades, while the latter does respect downgrades - i would consider the latter to be the better universal option

  • apt-get --just-print upgrade

    Is not read that easily, below is a perl one liner to parse apt-get's output:

    apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "PROGRAM: $1 INSTALLED: $2 AVAILABLE: $3\n"}'

    This should output something like:

    PROGRAM: grub-pc INSTALLED: 1.99-21ubuntu3.1 AVAILABLE: 1.99-21ubuntu3.9

    Hopefully it will help someone else,

    just for the laugh: apt-get -s upgrade| awk -F'[][() ]+' '/^Inst/{printf "Prog: %s\tcur: %s\tavail: %s\n", $2,$3,$4}'

    It could also be much more nice looking, if use `column` like this: `apt-get --just-print upgrade 2>&1 | perl -ne 'if (/Inst\s([\w,\-,\d,\.,~,:,\+]+)\s\[([\w,\-,\d,\.,~,:,\+]+)\]\s\(([\w,\-,\d,\.,~,:,\+]+)\)? /i) {print "PROGRAM: $1 INSTALLED: $2 AVAILABLE: $3\n"}' | column -s " " -t`

    @AntonioK Looks great!

    I'm afraid this Perl-code will hack my machine... ;)

    @AntonioK How do you sort the names of the programs alphabetically?

  • Another option, inspired by enzotib :

    aptitude search '~U' | wc -l

    This command will use aptitude to output the new packages and then wc to just count the lines.

    On a sidenote, I found that enzotib's solution without the single quotes around the ~U didn't work for me. (Wheezy, ZSH, aptitude

    Update :

    With the new apt you can do:

    apt list --upgradeable

    Thanks for this, the apt list command was exactly what I wanted.

    Nice with this solution is that you do not need sudo/root.

  • The easiest is:

    apt list --upgradeable

    does not work on mint.

    It's a shame this doesn't return different exit codes depending on whether there are upgrades available or not. Would have been nice to able to use this in a script.

  • You can run

    aptitude -F%p --disable-columns search ~U

    or the undocumented

    /usr/lib/update-notifier/apt-check -p; echo

    Another method using an apt-get simulation:

    apt-get -s dist-upgrade | awk '/^Inst/ { print $2 }'

    This aptitude command worked great for me and did not require root

    apt-get -s dist-upgrade works good too and has same output when you pipe it through that awker

    thank you! this got out of quite a bit of dependency hell. was trying to `dist-upgrade` but not lose some packages so needed to use `aptitude`. `aptitude install $(apt-get -s dist-upgrade | awk '/^Inst/ { print $2 }')` did the trick!

  • Take a look at package "apticron":

    apticron - Simple tool to mail about pending package updates

    Apticron is a simple script which sends daily emails about pending package updates such as security updates, properly handling packages on hold both by dselect and aptitude.

    Your link is broken...

  • apt-get update && apt-get -s upgrade

    will list available updates without actually installing.

    First command updates package index files before simulated (thus -s) upgrade is done. "-s" will do a simulated upgrade showing packets that would be installed but will not actually install anything.

    On the contrary "-u" instead of "-s" would actually install after confirmation.

    The simulate option can be triggered with any of `-s, --simulate, --just-print, --dry-run, --recon, --no-act`, recon and dry-run are my personal favorites.

  • I needed full version information on possible upgrades, so I used a modification of jasonwryan's answer:

    apt-get -V -u upgrade

    It's simple and IMO reasonably formatted output.

  • Just filter the output of

    apt-get update && apt-get -s -V -u upgrade

    to have only the preferred information in your log.

    Most likely, you'll need the beautiful part after the line


    The following packages will be upgraded:


    that has few spaces in the beginning.

    Hi and welcome to the site. As it stands, your answer is basically a rehash of existing ones and so does not add anything new. You could improve it by, for example, explaining how to filter the output, adding an explanation of what the various switches do etc.

  • apt-get update > /dev/null && apt-get --just-print upgrade | grep "Inst "

    is the most simple for cron emails; there is no user iteration, and if there are no updates there is no output.

License under CC-BY-SA with attribution

Content dated before 6/26/2020 9:53 AM