(Last Updated On: July 11, 2018)

On my last tutorial, I talked about complete steps of installing Arch Linux on a Bare metal system and on Virtual Machine. This tutorial can be accessed through the link below.

Installing Arch Linux from Scratch with KDE, GNOME, XFCE and Cinnamon DE step by step

Today, I will share with you Pacman and Yaourt Package Manager Mastery Cheatsheet. I’ll also show you my lifesaver list of Pacman and yaourt aliases. So let’s get started.

What is Pacman?

Pacman is a package manager used in Arch Linux and other Arch-based Distributions like Manjaro, Blackwatch, KaOS, LinHES, Antergos, Apricity OS, Arch Assault, BBQLinux, Bluestar, Bridge Linux, Ninja OS, PacBSD, Archiso, Kademar e.t.c.

Also check: yay – Best AUR Helper for Arch Linux / Manjaro

Pacman is mainly developed by Arch Linux developers and used to manage software packages; install, upgrade, configure and remove software packages.

Pacman package manager is written in the C programming language and uses the .pkg.tar.xz package format. It maintains a text-based package database hence allows you to query the package database for installed packages, files, and owners of those files.One special feature of Pacman is its reliable way of handling dependencies and conflicts automatically.

Manually Install Pacman

Since the development of Pacman is currently hosted on git, you can easily fetch the current development tree using git command.

# git clone git://projects.archlinux.org/pacman.git pacman

Pacman and yaourt package manager mastery Cheat Sheet

The list has commands for:

  • Doing system update
  • Install software packages with pacman and yaourt
  • Installing software packages locally available
  • How to install software packages from the internet
  • Removing software packages
  • Searching software packages in the local database or online repositories.
  • Create aliases for pacman and yaourt
  • Pacman Optimization Tips

System Update:

Update the system using:

$ sudo pacman -Syu

To synchronize your local database with repositories before upgrading packages that are out of date on the local system, type below command on your terminal:

$ sudo pacman -Syy

You can imultaneously synchronize with the repositories and update the system, enter below command:

$ sudo pacman -Syyu

Removing software packages

The syntax of removing a software package while retaining its configuration(s) and required dependencies are:

$ sudo pacman -R < Package name>

Example:

$ sudo pacman -R geany

Remove software package and its dependencies, provided those dependencies are not required by any other installed package:

$ sudo pacman -Rs < Package name>

Example

$ sudo pacman -Rs geany

To remove a package, its dependencies and configuration files generated by Pacman, enter the command:

$ sudo pacman -Rns < Package name>

Example:

$ sudo pacman -Rns geany

The -n option prevents saving of important configuration files with passive extension. It prevents creation of backup files.

To remove a package, its dependencies and all packages depending on the target package, enter the command:

$ sudo pacman -Rsc <package name>

Example:

To remove a package required by another package, without removing the dependent package, the command syntax is:

$ sudo pacman -Rdd <package name>

Example:

$ sudo pacman -Rdd libproxy

Installing Packages

Arch avoid refreshing package list without upgrading the system. It is, therefore, recommended to run

$ pacman -Syu <package name>

This will help you avoid any dependency issue that may arise.

To install a specific package from repositories including required dependencies, issue command below in your terminal:

$ sudo pacman -S <package name>

Example:

$ sudo pacman -S vlc

Pacman will automatically detect required dependencies and install them for you

To install a list of packages:

$ sudo pacman -S vlc firefox geany vim os-prober

Will install the packages mentioned above; vlc, firefox, geany, vim, and os-prober. It will automatically detect required dependencies and install them as well.

To download software package without installing it. enter the command:

$ sudo pacman -Sw <package name>
$ sudo pacman -Sw vim

To install a package from the specific repository, issue command with syntax below.

$ pacman -S [repository]/[package name]

Example is:

$ sudo pacman -S extra/vim

Will install vim from extra repository specified in /etc/pacman.conf file.

If you want to install packages belonging to a group, you’ll have to specify the name of the group.

$ sudo pacman -S vim-plugins

You can install all packages in the group or pick a specific package from the group.

Arch package groups

A list of available package groups can be found on Official Arch Linux page:

https://www.archlinux.org/groups/

Most common ones being:

base,base-devel,devel,firefox-addons,gnome,gnome-extra,kde-applications, \
kdebase,kdeadmin,kdegames,kdemultimedia,kdenetwork,kdeutils,kdo-addons, \
linux-tools,libreoffice-extensions,lv2-plugins,l,xde,mate,mate-extra,plasma, \
qt,qt5,vim-plugins,xfce4,xfce4-goodies,xorg,xorg-apps,xorg-drivers,xorg-fonts, \
tessaract-data

Installing Locally available packages or from the internet; not repositories.

To install a package already downloaded onto the system. It should have extension pkg.tar.xz, then you can issue a command to install as shown below:

$ sudo pacman -U <path-to-pkg.tar.xz-package>

Search Package

Display information about a given package in the local database

$ sudo pacman -Qi <package-name>

Search for package(s) in the local database

$ sudo pacman -Qs <package-name>

Search for package(s) in the repositories

$ sudo pacman -Ss <package-name>

Display information about a given package in the repositories

$ sudo pacman -Si <package-name>

Create aliases for Pacman and yaourt

My Pacman and yaourt Alias list. You can modify as you want and add them to your ~/.bashrc or ~/.zshrc file.

My Pacman Alias commands:

alias pacu='sudo pacman -Syu' # Update the system and upgrade all system packages.
alias paci='sudo pacman -S' # Install a specific package from repos added to the system
alias pacl='sudo pacman -U' # Install specific package that has been downloaded to the local system
alias paci='pacman -Si' # Display information about a given package located in the repositories
alias pacs='pacman -Ss' # Search for package or packages in the repositories
alias pacr='sudo pacman -R' # Remove the specified package or packages but retain its configuration and required dependencies
alias pacrall='sudo pacman -Rns' # Remove the specified package or packages , its configuration and all unwanted dependencies
alias pacsl='pacman -Qi' # Display information about a given package in the local database
alias paclocs='pacman -Qs' # Search for package/packages in the local database
alias yaconf='yaourt -C' # Fix all configuration files with vimdiff

Yaourt Alias commands.

alias yau='yaourt -Syua' # Synchronize with repositories and upgrade packages out of date in the system, including AUR packages.
alias yaui='yaourt -S' # Install a specific package from repos added to the system
alias yaul='yaourt -U' # Install specific package that has been downloaded to the local system
alias yaur='yaourt -R' # Remove the specified package or packages but retain its configuration and required dependencies
alias yaurall'yaourt -Rns' # Remove the specified package or packages , its configuration and all unwanted dependencies
alias yaui='yaourt -Si' # Display information about a given package located in the repositories
alias yaus='yaourt -Ss' # Search for package or packages in the repositories
alias yauil='yaourt -Qi' # Display information about a given package in the local database
alias yausl='yaourt -Qs' # Search for package(s) in the local database
alias yaul='yaourt -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
alias yauo='yaourt -Qtd' # Remove orphans using yaourt

Pacman Additional Tips

Reinstalling all packages

# pacman -Qnq | pacman -S -

Optimize Package database

# pacman-optimize

List all packages installed from a given repository

# paclist <reponame>

E.g. To list packages installed from core repo, do:

# paclist core

If you Love what we do, support us by downloading this tutorial as pdf from the link below:

References:

https://wiki.archlinux.org/index.php/Pacman_Tips
https://www.archlinux.org/pacman/
https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Performance

Also check: yay – Best AUR Helper for Arch Linux / Manjaro

Search Tags:

Pacman and yaourt package manager mastery Cheat Sheet
Arch Linux Pacman and yaourt package manager Tutorials
Basic Pacman commands for newbies
Learn to use Pacman and Yaourt for AUR