pacman -Syu: updating Arch Linux
To update Arch Linux, run sudo pacman -Syu. That single command is the supported way to upgrade, and running it is one transaction: the databases are refreshed and the packages are upgraded together.
sudo pacman -Syu
-S- --sync — install packages from the repositories and upgrade the system
-y- --refresh — refresh the package databases from the mirrors
-u- --sysupgrade — upgrade every installed package that is out of date
Needs root.
What it does. Refresh every package database, then upgrade every installed package that is out of date, in one transaction.
Watch out. Arch expects the whole system to move together: upgrading one package without the rest is the failure mode this command exists to avoid.
Step by step
- Refresh and upgrade in one command
Run the whole upgrade as a single transaction rather than refreshing first and upgrading later.
routinesudo pacman -Syu - Read the list before you answer
pacman prints the packages it will install, remove or replace, along with the download and installed size, and waits for an answer. This is the moment to notice a package being removed that you did not expect.
- Reboot if the kernel package changed
Kernel modules are stored per kernel version, so once the kernel package has been replaced the running kernel no longer has matching modules on disk. Anything that loads a module after that point fails until the machine has rebooted.
What each letter does
Three characters, three separate jobs, and they act in three different places:
| Part | Long form | What it does on its own |
|---|---|---|
-S | --sync | The synchronise operation: work against the repositories |
y | --refresh | Download the package databases again from the mirrors |
u | --sysupgrade | Upgrade every installed package that is older than the repository version |
Only u upgrades anything. y on its own downloads a newer description of what
the repositories contain and stops there, which is exactly where the trouble
starts.
Why a bare -Sy is the famous trap
This is the single most repeated warning about pacman, and the partial upgrade page takes it apart in full.
A partial upgrade is a system where the package databases describe new versions but most installed packages are still at their old versions, so a package installed afterwards is built against libraries the machine does not have.
After -Sy, the next -S <package> installs the new version of a package, which
expects the new versions of its dependencies — and those are still
sitting at the old version on disk. The installed program then fails to start,
usually complaining about a missing library file.
Do not refresh without upgrading. sudo pacman -Sy <package> is the shortest way to a partial upgrade. If you want one package, run sudo pacman -Syu <package> and take the whole upgrade with it.
When a doubled letter is needed
Repeating a letter changes it, and two of those repeats show up in real upgrades:
| Command | What the repeat adds | When it is needed |
|---|---|---|
sudo pacman -Syyu | Refresh the databases even when they look up to date already | After changing the mirrorlist, because the new mirror's database can be older than the one already on disk and would otherwise be skipped |
sudo pacman -Syuu | Allow a package to be replaced by an older version from the repository | When a package on the machine is newer than anything the repositories carry, for example after a repository was disabled |
-Syuu moves packages backwards. Going backwards is not an upgrade path the distribution supports, and it can leave two packages expecting different versions of the same library.
Holding a package back
Excluding a package from an upgrade is possible, and worth knowing mostly so
that you recognise what it costs. The
holding a package back page covers the standing
form of it in pacman.conf:
sudo pacman -Syu --ignore <package>Everything else moves forward and the named package does not, which is a partial upgrade you have chosen deliberately.
Common questions
How do I update Arch Linux?
Run sudo pacman -Syu. That refreshes the package databases from the mirrors and upgrades every installed package that is out of date, in one transaction.
What does pacman -Syu do?
-S is the synchronise operation, y refreshes the package databases from the mirrors, and u upgrades every installed package that is older than the version the refreshed databases describe.
Is pacman -Sy safe?
On its own it only rewrites the package databases, but it leaves the machine describing new versions while still running old ones. Anything installed after that point pulls in a new package against old dependencies, which is the partial upgrade that breaks programs. Use -Syu instead.
What is the difference between -Syu and -Syyu?
The doubled y forces the databases to be downloaded again even when pacman considers them current. It is needed after switching mirrors, because the new mirror may carry a database that is older than the one already on disk.