DEV Community

Cover image for How to use Pacman on Arch Linux πŸš€
Miguel Neto
Miguel Neto

Posted on

How to use Pacman on Arch Linux πŸš€

Pacman is the official Arch Linux package manager (which of course is used in other Arch-based distros, such as Manjaro). It features dependency support, package groups, install and uninstall scripts, etc. You can read all the details on the man page for Pacman.

In this article we’ll explore everything you need to know about package management on an Arch-Based distribution, through examples.

Installing and uninstalling packages

To install a package, run pacman -S (as root, of course). If I wanted to install vim, for example, I can run:

sudo pacman -S vim
Enter fullscreen mode Exit fullscreen mode

This will install vim and all the packages it depends on. Now, if you want to uninstall a program, for example vim, run:

sudo pacman -Rns vim
Enter fullscreen mode Exit fullscreen mode

This will remove vim, all of its dependencies, and all of its system configuration files.

Updating

To update all of your programs if they have new versions, run:

sudo pacman -Syu
Enter fullscreen mode Exit fullscreen mode

This will update the package list and upgrade all packages afterwards. Here, -S means sync, y means synchronize package databases (without updating), and u means update.

Searching for a package

If you want to search for a program, let’s say vim, run the following command:

pacman -Ss vim
Enter fullscreen mode Exit fullscreen mode

This is going to search for names or descriptions that has β€˜vim’ on it.

Listing packages

To list out all of the packages installed on your system:

pacman -Q
Enter fullscreen mode Exit fullscreen mode

To list the programs that you explicitly installed, without its dependencies:

pacman -Qe
Enter fullscreen mode Exit fullscreen mode

To list out all of the packages installed on your system, but show only the names of the programs:

pacman -Qeq
Enter fullscreen mode Exit fullscreen mode

To list only programs installed from the main repository:

pacman -Qn
Enter fullscreen mode Exit fullscreen mode

To list only programs installed from the AUR:

pacman -Qm
Enter fullscreen mode Exit fullscreen mode

To list all unneeded dependencies:

pacman -Qdt
Enter fullscreen mode Exit fullscreen mode

Cleaning up packages

To remove all the unnecessary packages from the cache and remove unused repositories:

sudo pacman -Sc
Enter fullscreen mode Exit fullscreen mode

Conclusion

Mastering the Pacman package manager is an essential skill for any Arch Linux user. With Pacman, you can easily manage your system’s software, install new packages, and keep your system up to date. By following the steps outlined in this article, you should now have a basic understanding of how to use Pacman to manage your Arch Linux system.

Happy hacking! πŸ’»πŸŒŒ

Top comments (0)