
How do you update Arch Linux? You run sudo pacman -Syu
command.
How do you install a package on Arch Linux? You run sudo pacman -Syu package_name
.
Which might make you wonder why do you need a system update while installing a new package? What does those S, y and u do? Let me explain these things to you.
What does pacman -Syu does?
In simpler words, pacman -Syu
updates all the installed packages on your Arch-based Linux distribution if they have a newer version available. Here, -S
stands for sync
or install, y
refreshes the local package database cache with the remote repository and u
will make a list of all the install packages that can be updated by referring to the local package database cache and getting actual packages from the remote repository.
Understanding pacman -Syu command
I hope you are familiar with the concept of package manager. If not, please refer to this explainer article:

Pacman package manager works pretty much the same. There is a remote repository that has the actual packages, a local package database that usually keeps the information about the packages by interacting with the remote repository. pacman is the command line interface that utilizes this structure to manage packages on your Arch Linux.

-S
(capital letter S) is the main option and y
and u
are 'sub-options' supporting it.
S stands for sync but you can think of it as 'install'. It syncs your Arch Linux system with the remote repository for the given package. Meaning, both repository and local Arch system will be synced (at that time) for the given package. Which is another way of saying that the package is installed on the system.
You cannot just run pacman -S
and expect it to sync (install) all the packages from the repositories on the local system. That would be disastrous if your system installs all 40,000+ packages of the remote repositories.
This is why you need to provide a target (package names) with only -S
option. Otherwise, you'll see this error.
sudo pacman -S
error: no targets specified (use -h for help)
If you specify a package or group name, it will 'install' the package on your system.
There are additional options with Sync. You'll probably be using a lot of sudo pacman -Syu
.
Those y
and u
are 'sub options' of -S
. You cannot use them on their own like pacman -yu
:
sudo pacman -yu
error: invalid option '-y'
While the order of S, y and u doesn't matter, there has to be an S with y and u.
The y
sub-option of S
refreshes the local package cache DB with remote repository. Then u
sub-option is for sysupgrade which refers to the local package cache to make a list of all the installed packages that can be upgraded to a newer version.
With the work of these two sub options done, S
(sync) will fetch the packages (newer versions) from the remote repository and install (update existing) them.
r
for refresh instead of y
. Easier to understand.Why most tutorials mention "pacman -Syu" even while installing a single package?
You'll notice that many tutorials often mention the pacman command for package installation in the following format:
sudo pacman -Syu package_name
And you may wonder what's the point of updating all the installed packages.
Sure, you can use sudo pacman -S package_name
for installing packages, and it will run fine if you keep your Arch system updated frequently.
But if you haven't run the system updates for a while, installation may throw 404 missing file error. You need to update the local package database.
Now, you may think, why not just do sudo pacman -Sy package_name
which would be quicker as it will refresh package database and install only the package you want, not upgrade other packages that have newer versions available?
There is a pretty good reason for that. It helps avoid the dependency issues that could occur otherwise.
I liked the analogy in this Reddit discussion and I am going to use the same here as well.
Imagine an old-fashioned paper catalog folks used to get in the mail a few decades back. If you get a catalog in the mail from a store, it had a listing of everything the store had for sale and the current prices. The Arch package database is like this catalog. The catalog you have with you is the package database cache on your system.
The packages are like the actual goods you buy through the catalog. You find the item number that you want in the catalog, place the order, and the correct item is delivered.
Imagine you just run pacman -Sy
. This is equivalent to getting the latest catalog.
Now, let's say you have an iPhone 14 (an outdated package) and you order an iPhone charger from the new catalog. You'll have a problem when the new charger arrives because the iPhone now uses the type C port instead of the old lightning port. A conflict arises.
If you had run pacman -Syu
, you would have ordered both the newer iPhone and the correct charger with it.
(Don't take it literally and start commenting that it will be a financially stupid decision to order a new phone instead of the older charger. This is just for example ๐)
Conclusion
I don't know whether you were ever curious about it or not, but I do hope you have a slightly better understanding of the logic behind the famous -Syu option of pacman command. The man page is always there to read the official explanation of each option and its usage.
You can always explore more options of the pacman command to see what it can do for regular package management on Arch Linux.

๐จ๏ธ Did this article help you understand the 'sync' concept in Arch Linux, or are you more confused than before? Do let me know in the comment section.