Pacman is the default command line package management tool for Arch Linux and its derivatives. With it you can easily install, remove, update, and upgrade packages along with all required dependencies.
Pacman, stands for Package Manager. It is one of the main difference between Arch Linux and other major distributions like RedHat/Fedora/CentOS and Ubuntu/Debian. It combines a simple binary package format with an easy-to-use build system. The aim of pacman is to easily manage software packages.
So, let see how to use pacman to install, remove, update, and querying packages in Arch Linux with simple examples.
Refresh package lists
Like in all Linux operating systems, before installing any packages, or updating the system, we must update the package lists.
pacman -Sy
:: Synchronizing package databases...
core 132,1 KiB 2,58 MiB/s 00:00 [######################] 100%
extra 1663,6 KiB 3,48 MiB/s 00:00 [######################] 100%
community 5,1 MiB 3,17 MiB/s 00:02 [###############################] 100%
multilib 162,2 KiB 2,64 MiB/s 00:00 [################################] 100%
Searching for package
To search for a specific package, for example vlc, from a sync database (remote server), run:
pacman -Ss vlc
extra/phonon-qt5-vlc 0.11.1-2
Phonon VLC backend for Qt5
extra/vlc 3.0.11.1-1
Multi-platform MPEG, VCD/DVD, and DivX player
community/playerctl 2.2.1-1
mpris media player controller and lib for spotify, vlc, audacious, bmp, xmms2, and others.
Getting information about package
To display the detailed information of the given package from the sync database, run:
pacman -Si vlc
Repository : extra
Name : vlc
Version : 3.0.11.1-1
Description : Multi-platform MPEG, VCD/DVD, and DivX player
Architecture : x86_64
URL : https://www.videolan.org/vlc/
Licenses : LGPL2.1 GPL2
Groups : None
Provides : None
Depends On : a52dec libdvbpsi libxpm libdca libproxy lua libidn libmatroska taglib libmpcdec ffmpeg faad2 libupnp
libmad libmpeg2 xcb-util-keysyms libtar libxinerama libsecret libarchive qt5-base qt5-x11extras qt5-svg
freetype2 fribidi harfbuzz fontconfig libxml2 gnutls libplacebo wayland-protocols aribb24
Optional Deps : avahi: service discovery using bonjour protocol
aom: AOM AV1 codec
gst-plugins-base-libs: for libgst plugins
dav1d: dav1d AV1 decoder
libdvdcss: decoding encrypted DVDs
.........
Conflicts With : vlc-plugin
Replaces : vlc-plugin
Download Size : 11,68 MiB
Installed Size : 57,72 MiB
Packager : Maxime Gauduin <alucryd@archlinux.org>
Build Date : 5.08.2020 (ср) 9:17:43
Validated By : MD5 Sum SHA-256 Sum Signature
Installing package
Installing a package with pacman is really easy. Just run the following command:
pacman -S vlc
resolving dependencies...
looking for conflicting packages...
Packages (11) aribb24-1.0.3-3 glslang-8.13.3743-1 libdvbpsi-1:1.3.3-2 libebml-1.4.0-1 libmatroska-1.6.2-1 libplacebo-1.29.1-3
libtar-1.2.20-5 libupnp-1.6.25-2 shaderc-2020.0-1 spirv-tools-2020.2-1 vlc-3.0.11.1-1
Total Download Size: 15,59 MiB
Total Installed Size: 80,28 MiB
:: Proceed with installation? [Y/n]
As a result, this process will automatically identify all the necessary dependencies and take care of it.
Installing a local package
Pacman stores all downloaded packages in /var/cache/pacman/pkg/ folder. In case, you want to install the locally downloaded package, for example vlc located into /var/cache/pacman/pkg/ directory, go to the folder where the package is located and enter the following command:
cd /var/cache/pacman/pkg/
pacman -U vlc-3.0.11-2-x86_64.pkg.tar.zst
Update / Upgrade a package
To update a single package, for example rsync, run:
pacman -S rsync
resolving dependencies...
looking for conflicting packages...
Packages (1) rsync-3.2.3-1
Total Download Size: 0,30 MiB
Total Installed Size: 0,57 MiB
Net Upgrade Size: 0,01 MiB
To update all packages in your system, just run:
pacman -Syu
:: Synchronizing package databases...
core is up to date
extra is up to date
community is up to date
multilib is up to date
:: Starting full system upgrade...
resolving dependencies...
looking for conflicting packages...
Packages (58) accerciser-3.36.3-1 ansible-2.9.12-1 attica-5.73.0-1 epiphany-3.36.4-1 ffmpeg-2:4.3.1-2 file-roller-3.36.3-1 gdm-3.36.3-3 gnome-desktop-1:3.36.5-1 gst-plugins-ugly-1.16.2-4 ....
Total Download Size: 96,07 MiB
Total Installed Size: 508,63 MiB
Net Upgrade Size: -0,27 MiB
:: Proceed with installation? [Y/n]
Sometimes you want to upgrade the packages but for one particular package, you want it to stay at an older version (because you know the newer version has removed a feature or is broken). So, if vlc was causing the problem, you could use the following command for this:
pacman -Syu --ignore=vlc
Remove a package
In order to remove a package with all its dependencies, run the following command:
pacman -Rs vlc
checking dependencies...
Packages (11) aribb24-1.0.3-3 glslang-8.13.3743-1 libdvbpsi-1:1.3.3-2 libebml-1.4.0-1 libmatroska-1.6.2-1 libplacebo-1.29.1-3
libtar-1.2.20-5 libupnp-1.6.25-2 shaderc-2020.0-1 spirv-tools-2020.2-1 vlc-3.0.11.1-1
Total Removed Size: 80,28 MiB
:: Do you want to remove these packages? [Y/n]
This command will completely remove vlc package and all dependencies. Pacman will keep the important configuration files with the extension: .pacsave while removing packages.
In addition, if you no longer want them and want to free up hard drive, you can remove the package along with all its configuration files with command:
pacman -Rns vlc
Remove orphaned (unused) packages
As you might know, there will still be some orphaned (unused) packages in your Arch Linux after removing a package. These orphaned packages are not required anymore, so we can get rid of them to free up some space. To remove these packages, run:
pacman -Rns $(pacman -Qdtq)
If no orphans were found, the output is:
error: argument '-' specified with empty stdin
Which applications are installed on your computer
You can view a list of all the packages installed on your system using the following command:
pacman -Q
As a result this will return a list of all the applications on your computer and their version numbers.
Searching for already installed packages
Sometimes you want to check for a specific package if it is installed locally. In this case you can do it using the command below:
pacman -Qs vlc
local/vlc 3.0.11.1-1
Multi-platform MPEG, VCD/DVD, and DivX player
You can view a list of all the packages installed on your system using the following command:
pacman -Q
Find all files owned by a package
You can find all the files that are installed by a specific package using the following command:
pacman -Ql vlc
vlc /usr/
vlc /usr/bin/
vlc /usr/bin/cvlc
vlc /usr/bin/nvlc
vlc /usr/bin/qvlc
vlc /usr/bin/rvlc
vlc /usr/bin/svlc
vlc /usr/bin/vlc
vlc /usr/bin/vlc-wrapper
vlc /usr/include/
vlc /usr/include/vlc/
vlc /usr/include/vlc/deprecated.h
vlc /usr/include/vlc/libvlc.h
...
This returns the package name and the path to files that it owns.
Find the package owner of the file
If you want to check the location of the binary executable file owned by a package, use the -Qo flag.
pacman -Qo /usr/bin/vlc
/usr/bin/vlc is owned by vlc 3.0.11.1-1
Download a package
Sometimes, you might want to just download a package and keep it in your cache without installing it. For example, you might plan to use the downloaded packages in future. To do so, run:
pacman -Sw vlc
resolving dependencies...
Packages (1) vlc-3.0.11.1-1
Total Download Size: 11,68 MiB
:: Proceed with download? [Y/n]
:: Retrieving packages...
vlc-3.0.11.1-1-x86_64 11,7 MiB 3,71 MiB/s 00:03 [################################] 100%
(1/1) checking keys in keyring [################################] 100%
(1/1) checking package integrity [################################] 100%
The above command will only download the vlc package, and keep it in the cache folder. Pacman stores all downloaded packages in /var/cache/pacman/pkg/ folder.
Clean up package cache
All packages that we downloaded during the installation will be stored in the cache directory i.e /var/cache/pacman/pkg/. If you don’t remove them periodically, it will slowly eat up your hard drive space, and sooner or later you could end up with low disk space.
So it is good to remove the cache periodically. To remove all the cached packages that are not currently installed, and the unused sync database, execute:
pacman -Sc
Packages to keep:
All locally installed packages
Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove all other packages from cache? [Y/n]
removing old packages from cache...
Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n]
removing unused sync repositories...
In addition, if you want to remove all files from the cache, use the clean ‘c’ switch twice. Of course, this is the most aggressive approach and will leave nothing in the cache folder:
pacman -Scc
Cache directory: /var/cache/pacman/pkg/
:: Do you want to remove ALL files from cache? [y/N] y
removing all files from cache...
Database directory: /var/lib/pacman/
:: Do you want to remove unused repositories? [Y/n]
removing unused sync repositories...