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.
Today, I will share with you Pacman Package Manager and Yay Mastery Cheatsheet. I’ll also show you my lifesaver list of Pacman and Yay 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.
Pacman and Yay package manager mastery Cheat Sheet
The list has commands for:
- Doing system update
- Install software packages with pacman and Yay
- 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 Yay
- 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
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
Example
sudo pacman -Rs geany
To remove a package, its dependencies and configuration files generated by Pacman, enter the command:
sudo pacman -Rns
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
Example:
To remove a package required by another package, without removing the dependent package, the command syntax is:
sudo pacman -Rdd
Example:
sudo pacman -Rdd libproxy
Installing Packages on Arch Linux
Arch avoid refreshing package list without upgrading the system. It is, therefore, recommended to run
pacman -Syu
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
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
sudo pacman -Sw vim
To install a package from the specific repository, issue command with syntax below.
sudo 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:
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
Search Package
Display information about a given package in the local database
sudo pacman -Qi
Search for package(s) in the local database
sudo pacman -Qs
Search for package(s) in the repositories
sudo pacman -Ss
Display information about a given package in the repositories
sudo pacman -Si
Create aliases for Pacman and Yay
My Pacman and Yay 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 but retain its configuration and deps
alias pacrall='sudo pacman -Rns' # Remove package, 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
Yay Alias commands.
alias yu='yay -Syua' # Synchronize with repositories and upgrade packages, including AUR packages.
alias yi='yay -S' # Install a specific package from repos added to the system
alias yil='yay -U' # Install specific package that has been downloaded to the local system
alias yr='yay -R' # Remove package but retain configs and required dependencies
alias yrall='yay -Rns' # Remove package or packages , its configuration and all unwanted dependencies
alias yip='yay -Si' # Display information about a given package located in the repositories
alias ys='yay -Ss' # Search for package or packages in the repositories
alias yil='yay -Qi' # Display information about a given package in the local database
alias ysl='yay -Qs' # Search for package(s) in the local database
alias yll='yay -Qe' # List installed packages, even those installed from AUR (they're tagged as "local")
alias yro='yay -Qtd' # Remove orphans using yay
Pacman Additional Tips
Reinstalling all packages
pacman -Qnq | pacman -S -
Optimize Package database
sudo pacman-optimize
List all packages installed from a given repository
sudo paclist
E.g. To list packages installed from core repo, do:
sudo paclist core