I know that pacman -Su
upgrades all packages. But how can I get just the list of packages that need upgrading?

- 2,433
- 5
- 34
- 54
3 Answers
checkupdates
The bash script
checkupdates
, included with the pacman-contrib package, provides a safe way to check for upgrades to installed packages without running a system update at the same time.

- 171
- 8

- 331
- 2
- 3
-
3This should be the correct answer – Nitz Apr 25 '20 at 10:01
-
Brilliant mate! – smac89 Oct 15 '20 at 04:43
Looking at the man page something like
pacman -Sy
to sync the database up to the latest version followed by
pacman -Qu
to
-u, --upgrades
Restrict or filter output to packages that are out of date on the
local system. (Only package versions are used to find outdated packages, replacements are not checked here.) This option works best if the sync database is refreshed using -Sy.
Please note that syncing the package list like this will leave you in a situation where you should not install or upgrade single packages, until you have performed the next full update.
In general you should not upgrade individual packages, because partial upgrades are not supported in Arch or Manjaro. If you see a package that needs upgrading, you should really run pacman -Syu
to upgrade all the packages at once.
While installing or upgrading a single package might work sometimes, there is a danger that it will upgrade a library it depends on, and that library upgrade could cause another package to break.

- 494
- 4
- 7

- 115,471
- 20
- 215
- 297
-
2**DANGER**: The documentation says "never run `pacman -Sy`" (source: https://wiki.archlinux.org/index.php/System_maintenance#Avoid_certain_pacman_commands) – blippy May 03 '16 at 14:34
-
2@blippy That document didn't exist when this answer was written, it's earliest revision is [some monhs later](https://wiki.archlinux.org/index.php?title=System_maintenance&oldid=194778). Furthermore, the statement to which you refer was not added to the document until (Oct 23 2015)[https://wiki.archlinux.org/index.php?title=System_maintenance&oldid=406240) over 4 years later. **Rather than being so melodramatic you should have just edited the answer and referenced the document as the reason for your change request** _Also note that even now the man page makes no such warnings._ – user9517 May 03 '16 at 17:05
-
4just want to clarify too - [the reason](https://wiki.archlinux.org/index.php/System_maintenance#Partial_upgrades_are_unsupported) for not running `pacman -Sy` is to avoid installing packages from different package database updates. e.g. `pacman -S
` may give you a different package and dependencies than `pacman -Sy && pacman -S – aaaaaa Mar 06 '18 at 19:22`. From their documentation however, it seems `pacman -Sy && pacman -Qu` is the correct answer to OP's question. Just make sure you eventually run `pacman -Su` prior to installing any packages. -
1I just want to clarify that the article is not saying `pacman -Sy` in-and-of-itself is bad. It doesn't even say it's "bad" or "dangerous". It is merely stating that a partial upgrade is not supported and that you should avoid it. In other words, running `pacman -Sy` *and then* running `pacman -S
` has the potential to break something else that has the same dependencies. Running something like `pacman -Sy && pacman -S man-pages` to only get the latest man-pages would be perfectly fine (man-pages has no dependencies, and is not required by any other packages). – Drew Chapin Sep 09 '18 at 22:33 -
2It's 5 days later when you've forgotten you ran `pacman -Sy` and run `pacman -S nvidia` that you're likely to break something. – Drew Chapin Sep 09 '18 at 22:35
-
I'm very very confused the question is "how can I get just the list of packages that need upgrading?" and you provide a command that actually DO update the list of package locally and then ask if you actually want to proceed with installation. As it is VERY important to NEVER update the list of packages (and their version) without actually updating the packages as otherwise it is a partial upgrade which you should not do (otherwise when you iunstall new package they may not work as they assume you have the package from your local package list). – Ilan Schemoul Sep 30 '20 at 15:23
As @Panagiotis mentioned, checkupdates
provides a way to do this without requiring root or messing up your /var/lib/pacman
database. Here's a minimal version of checkupdates
:
TMPPATH="${TMPDIR:-/tmp}/checkup-db-${USER}"
DBPATH="$(pacman-conf DBPath)"
mkdir -p "$TMPPATH"
ln -s "$DBPATH/local" "$TMPPATH" &>/dev/null
fakeroot -- pacman -Sy --dbpath "$TMPPATH" --logfile /dev/null &>/dev/null
pacman -Qu --dbpath "$TMPPATH" 2>/dev/null
It works by:
- Creating a temporary folder for your database.
- Symlinking your
/var/lib/pacman/local
. - Running
pacman -Sy
on your temporary folder. - Querying via
pacman -Qu
on your temporary folder.

- 135
- 7