opkg upgrade all packages

OpenWrt does not have bash by default. The following commands are in pure busybox.

  1. Get installed packages by calling opkg list_installed
  2. Remove everything after ‘ – ‘ with sed
  3. Add opkg upgrade at the beginning of each line
  4. Finally we evaluate the sed output with eval

Full command:

# eval $(opkg list_installed | sed 's/ - .*//' | sed 's/^/opkg upgrade /')
Tagged , , , . Bookmark the permalink.

28 Responses to opkg upgrade all packages

  1. Knutowskie says:

    Thank you very much! This is what i’m looking for! And it’s running nice!

  2. Pingback: Geoff's Place » OpenWRT update on an NSLU2 (and some minor OSX stuff mixed in as well)

  3. Olivier Berger says:

    Why not use opkg list-upgradable ?

  4. Peter Fern says:

    Instead, I’d suggest:

    opkg list-upgradable | xargs opkg upgrade

  5. sinkcup says:

    opkg list-upgradable | awk -F ' - ' '{print $1}' | xargs opkg upgrade

    • Nikolaj Løbner Sheller says:

      opkg list-upgradable | awk -F ‘ – ‘ ‘{print $1}’ | xargs -r opkg upgrade

  6. Allen Shaw says:

    opkg list-upgradable | cut -d ” ” -f1 | xargs -r opkg upgrade

  7. Rob Zwissler says:

    opkg upgrade `opkg list-upgradable|cut -f1 -d-`

  8. joe says:

    opkg upgrade $(opkg list-upgradable | cut -f1 -d ‘ ‘)

    I think you want use ‘ ‘ as a delimiter, since some package-names contain a ‘-‘

  9. jxd says:

    eval $(opkg list-upgradable |grep -v ‘Multiple packages’| sed ‘s/ – .*//’ | sed ‘s/^/opkg upgrade /’)

  10. :D says:

    OK, so here is mine:
    opkg upgrade $(opkg list-upgradable | awk ‘{ print $1 }’)


  11. Wolf says:

    Just why openWRT doesn’t integrate this fundamental update feature into OPKG command? Why make it complicate make no sense to me.

  12. SBartsch says:

    Thanks for (all) your Solution(s) xD

  13. I have created a script that lists the packages, let you confirm, etc. You can find it here:

    And this is my one-liner with opkg update included:

    opkg update >/dev/null; PACKS=”$(opkg list-upgradable | awk ‘{ printf “%s “,$1 }’)” && [[ ! -z “$PACKS” ]] && opkg install $PACKS || echo $’\nNo packages to install\n’

  14. router user says:

    Hillarious, most commands dont work:) What a terrible firmware – LEDE/OpenWRT – anyway. Remember the Asus merlin luxury – easy upgrades, all configuration preserved.

  15. C0rn3j says:

    This works for me

    # opkg update
    # opkg list-upgradable | awk -F ‘ – ‘ ‘{print $1}’ | xargs opkg upgrade

  16. Kevin Shenk says:

    I think the main reason most of these commands don’t work is because the blog engine is replacing single quotes with specialized in/out-quote characters that the terminal won’t understand. Considering that this post is a prominent Google search result, please integrate the best of these suggestions into the post in a way that actually preserves the integrity of the commands!

  17. Walter says:

    opkg upgrade $(opkg list-upgradable | sed ‘s/ -.*//’)

    This works for me without a hassle.

  18. Alberto da Silva says:

    opkg update
    opkg list-upgradable |
    while read PKG REST
    echo “opkg upgrade $PKG $REST”
    opkg upgrade $PKG

  19. DarkCraz says:

    opkg update&opkg upgrade $(opkg list-upgradable | awk ‘{ printf “%s “,$1}’)

  20. MerMuttRex says:

    Slightly simpler version of what C0rn3J posted above that worked for me:
    # opkg update
    # opkg list-upgradable | awk ‘{print $1}’ | xargs opkg upgrade

  21. J. Reis says:

    There seems to be some indication that this may be a terrible idea and isn’t actually supported by OpenWRT in any official way (which may account for the lack of any simple GUI way of performing this function):




    I’m not an openWRT expert, but this is still a top search result for “updating openwrt” despite its age and seems to be giving what may be very bad advice.

  22. Donny D. says:

    I use:

    for i in `opkg list-upgradable | awk -F’ – ‘ -e ‘{ print $1 }’`; do opkg upgrade $i; done

    As far as J. Reis’ comment goes… I’ve been applying package upgrades with this loop for several years now, and I have never run into any issues. The actual image still needs to be upgraded from time to time to cover newly discovered vulnerabilities.

Leave a Reply

Your email address will not be published. Required fields are marked *