Essential Pacman Commands for Arch Linux [With Examples]

5 min

The package manager pacman is a convenient utility. You can do a whole lot of things just using some simple commands. Here we take a look at some of the essential pacman command examples for Arch Linux (and other derivatives such as Manjaro) for your daily use. Have a look.

The pacman is the official package manager for Arch Linux. It is being used by all the Arch Linux derivatives, such as Manjaro. Using pacman you can do almost all types of package management operations, such as install, uninstall, download, build, etc. Hence it is essential to know various pacman example commands for daily use.

This guide gives you the reference commands for pacman to perform various operations. Hereโ€™s the table of contents of this guide.

Pacman command examples for Arch

Most of the commands that are used require admin privilege. So, use sudo or run these commands using an ID having admin privileges.

Examples where is present in the syntax, replace them using the actual name of your package in question. Also, most of the pacman commands described below accept multiple package names delimited by spaces wherever applicable.

1. Updating your system

This command sync and download the fresh copy of the master package database from the server, which is defined in pacman.conf file.

sudo pacman -Syy
-S: sync packages
-y: download fresh package database
y: the second y forces the download even if it is upto date
pacman -Syy
pacman -Syy

2. Upgrade system

pacman -Syu

This upgrades all out-of-date packages following the sync and downloads the fresh package database.

pacman -Syu
pacman -Syu

3. Upgrade a single package

If you want to update a single package, use the package name at the end. For example, if you want to upgrade firefox only, leaving other packages in your system, use the below.

pacman -S firefox

4. Search package

The following command searches a package in name and its description in the Arch repository (core, extra, and community).

pacman -Ss notepad++

This searches all substrings of the parameter passed. You do not need to use wild cards. However, depending on the search string, the result can be a lot. So, you might want to filter the result out using grep or something else.

Search a package
Search a package

5. Search Package with all Dependencies

pacman -Si package

This command is ideal for listing all the details about the package, such as dependencies, package versions, etc. Basically, all information about the package. Remember, you need the exact package name for this command to work. Wild card search doesn’t work in this command.

Search a package with dependencies - pacman command examples
Search a package with dependencies – pacman command examples

6. Install Package

Before you install any package, make sure to run pacman -Syu to make your system up to date.

If you know the package name, you can install it using the following command.

sudo pacman -S package

For example:

sudo pacman -S firefox

This command shows how much to be downloaded and what is the estimated disk space to be used after installation.

7. Download a package without installing

You do not always want to install a package. Sometimes you may want to download the package for offline installation. Example:

sudo pacman -Sw smplayer

The downloaded file is kept at /var/cache/pacman/pkg defined in the /etc/pacman.conf file.

8. Install a locally downloaded package

You can install local packages using the following syntax.

sudo pacman -U /path/to/package

9. Install package directly from URL

If you want to install any package directly from remote network computers, servers, or mirrors, you can easily do that by providing the URL.

sudo pacman -U http://โ€ฆ.

10. Re-install packages

You can re-install all packages installed in your system using the following command. Be cautious while running the below command, as it might be a huge list of packages, and download may take time.

pacman -Qnq | pacman -S -

11. Unsintall a package

Uninstallation is simple. Run the below command to uninstall a package.

sudo pacman -R package

However, the above command only uninstalls the package, not its dependencies.

12. Uninstall with dependencies that are not required by other apps

You can use different switches to uninstall a package using pacman, including all of its dependencies.

For example:

sudo pacman -Rsun firefox
  • n: Ignore backups – that is, remove backups as well
  • s: recursively remove each target that is not required by any other packages or manually installed
  • u: Remove packages not required by any other packages.

You can use any combination of the above switches for your need.

13. Show details about installed packages and dependencies

The following command shows the information of a package and its dependencies. The output contains the dependent packages, the list of packages on which this package is dependent upon and a list of optional dependencies.

pacman -Qi package

14. Complete list of installed packages

If you want a complete list of installed packages in your system, you may use the following command.

pacman -Q

You can redirect the output to a text file for further processing.

pacman -Q > complete_list.txt

You can also list explicitly installed packages that are not required by any other package, using the below command.

pacman -Qet

The above commands display the package name and versions delimited by space. You can only extract package names using the below:

pacman -Qe | awk '{print $1}'

15. Clean up system

You can use the following commands to perform several cleanup processes in your system.

The below command cleans the unused sync databases and packages no longer installed from the cache. So this removes all cache files that are not installed. Cache files are stored in /var/cache/pacman/pkg/.

First, you can check manually how much disk space is used by pacman cache files.

du -h /var/cache/pacman/pkg
Check disk space used by pacman cache
Check disk space used by pacman cache

Then you can run the following to clean.

sudo pacman -Sc
Clean pacman cache files
Clean pacman cache files

If you want to clear all cache files use the switch twice.

sudo pacman -Scc

The above commands can be super useful to free up disk space.

The pacman files

The followings are some of the important pacman files which are used by this package. You can analyze these for troubleshooting and configuration work.

  1. The main configuration file which contains pacman settings is –
  • Cached file location
  • Database file location
  • Logfile location, which contains all pacman commands you ran till date and details. You can analyze this file for troubleshooting purposes.

Wrapping Up

I hope these pacman command examples are useful for you for doing several pacman-related tasks in the Arch system. The options for pacman are huge, which you can read on man pages. However, this is a summary of essential pacman commands filtered out for reference.

What is that pacman command which you think should be included here? Let me know in the comments.


Creator and author of Connect with me via Telegram, ๐• (Twitter), or send us an email.
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Oldest Most Voted
Inline Feedbacks
View all comments