Pacman Overview
Overview
Pacman is a package manager developed specifically for use in Arch Linux. It is used to install, upgrade, configure and remove software (i.e. to manage software packages). Pacman is used through typing commands terminal; all the commands listed below to undertake various tasks assume that you have your terminal open.
Updating the System
To update your system, enter the following command in the terminal:
sudo pacman -Syu
Synchronising with the Manjaro Repositories
Your Manjaro system has a database of all the software packages (e.g. system updates and applications) that are available from the official repositories. This is used to help pacman locate and download these packages for installation. When updating your system, its database will automatically be refreshed as well. However, using this command is more thorough, as rather than just refreshing or updating the database, it will actually rebuild it completely. To synchronise your database with the Manjaro repositories, enter the following command in the terminal:
sudo pacman -Syy
To simultaneously synchronise with the repositories and update your system, enter the command:
sudo pacman -Syyu
Searching for Software Packages
It is also possible to use pacman to search Manjaro's software repositories for any desired software, provided you know the name of what you want. The sudo prefix is not required for this. To search for a software package in the Official Manjaro repositories, the basic syntax is:
pacman -Ss [software package name]
For example, to search the repositories to see if a text editor called Leafpad is available, the following command would be entered:
pacman -Ss leafpad
In addition, it is also possible to search for packages that have already been installed on your system. For basic information, enter the following command:
pacman -Q [software package name]
Otherwise, to gain far more comprehensive about an installed package, enter the following command:
pacman -Qi [software package name]
It is also possible to gain even more information, including related backup files as well as the date that the package was last altered by entering the command:
pacman -Qii [software package name]
Finally, for a list of all installed packages on your system, enter the following command:
pacman -Ql
Orphaned Software Packages
To list all orphans - that is, installed packages that are not used by anything else and that consequently serve no purpose - enter the following command:
pacman -Qdt
It is highly recommended to remove orphans from your system, as although harmless, they still serve no purpose other than to take up room and resources. Rather than having to remove them one-by-one, the following command will search for and remove them for you:
sudo pacman -Sc $(pacman -Qdtq)
Listing Information about Installed Packages
To list all dependencies of a particular software package (i.e. other software that requires the specified software package in order to work), enter the following command:
pactree [software package name]
Downloading and Installing Software Packages
Software packages may be downloaded and installed from a range of sources, and not just from the official Manjaro repositories. However, please note that where installing packages from unofficial sources, you so so entirely at your own risk!
Packages from the Manjaro Repositories
To install a software package, the basic syntax is:
sudo pacman -S [software package name]
For example, to download and install leafpad, the following command would be entered:
sudo pacman -S leafpad
It is also possible to download software packages without actually installing them by entering the following command:
sudo pacman -Sw [software package name]
Packages Located Locally or From the Internet
To install a package already downloaded onto your system (the file name should end in pkg.tar.xz), the basic syntax is:
sudo pacman -U [/package_path/][software package name.pkg.tar.xz]
For example, to install a package located in the Downloads folder, the following command would be entered:
sudo pacman -U ~/Downloads/[software package name.pkg.tar.xz]
To install a package via a URL (i.e. located elsewhere on the internet), the basic syntax is:
pacman -U http://www.examplepackage/repo/examplepkg.tar.xz
Removing Applications and Software Packages
To remove a software package, the basic syntax is:
sudo pacman -R [software package name]
For example, to remove the software application Leafpad, the following command would be entered:
sudo pacman -R leafpad
It is also possible to remove package and its dependencies, provided those dependencies are not being used by any other packages. Deleting dependencies exclusive to a certain package is wise, as once the main package is removed, they will become orphans, serving no other purpose than to clutter up your system. To do so, enter the following command:
sudo pacman -Rs [software package name]
However, Pacman usually also creates backup configuration files when deleting packages. As such, for a more thorough (and cleaner) removal (ie. the package, its dependencies, and any configuration files usually generated by pacman) enter the following command:
sudo pacman -Rns
Learning pacman's options
It is a very good idea to become familiar with the varied and powerful uses of pacman. A comprehensive list of options that can be used with pacman can be found by entering the following command:
man pacman
To exit out of the list, simply press q.
Intermediate Pacman Commands
Once the pacman basics have been mastered, a few extra tricks can be learned in order to undertake a wider variety of tasks.
Troubleshooting
A separate page for pacman troubleshooting is available here.