Using Pacman on Arch-Linux Distributions

Overview

Pacman is the package manager for Arch-Linux distributions.

  • Its fast. Very fast.
  • Its pretty (at least I think so).
  • You can easily manage repositories, whether official or custom.

But, one thing it is not is intuitive. So, I made some notes for a reference while learning Garuda Linux.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
pacman --help

# Output:
usage:  pacman <operation> [...]
operations:
pacman {-h --help}
pacman {-V --version}
pacman {-D --database} <options> <package(s)>
pacman {-F --files}    [options] [file(s)]
pacman {-Q --query}    [options] [package(s)]
pacman {-R --remove}   [options] <package(s)>
pacman {-S --sync}     [options] [package(s)]
pacman {-T --deptest}  [options] [package(s)]
pacman {-U --upgrade}  [options] <file(s)>

Use pacman {-h --help} with an operation for available options.

Quick Cheat Sheet Snippets Reference.

Eveyday Package Management

Search for a package:

pacman -Ss hugo

Install a package:

pacman -S hugo

Install or update a package:

pacman -Syu hugo

Remove a package:

pacman -Rsc hugo

Eveyday Package Queries

Search installed packages for keywords:

pacman -Qs <query>

List information on a package:

pacman -Qii hugo

List all explicitly install packages:

pacman -Qe

List files associated with a file:

pacman -Ql hugo

Finding Dependencies

What does a package depend on?

pactree hugo

What packages depend on a package?

pacman -r hugo

Finding Orphaned Packages

List unneeded or orphaned packages:

pacman -Qdt

Remove unneeded or orphaned packages:

pacman -Rns $(pacman -Qdtq)

Pacman Performance

Some tips for increasing performance.

Avoid slow downloads and time-out errors while installing and updating packages by updating the mirrorlist file. For this we can use:

Reflector does the heavy lifting for us. Lets use that.

Reflector

Reflector is a python script that,

  • checks and retrieves the most up-to-date mirror list for each country.
  • can sort by speed and age.
  • can update the mirror list file automatically: /etc/pacman.d/mirrorlist.

Set the mirror list according to your country.

Finding Country Code

List unneeded or orphaned packages:

reflector --list-countries

Sample Output:

1
2
3
4
5
6
7
8
Country                Code Count
---------------------- ---- -----
Argentina                AR     2
Australia                AU    20
Austria                  AT    11
Azerbaijan               AZ     4
Bangladesh               BD     1
Belarus                  BY     4
Update Mirror List by Country Code

sudo reflector --country 'NZ, AU' --sort rate --save /etc/pacman.d/mirrorlist

Updating the mirror list and sorting by download rate.

  • --country New Zealand and Australia.
  • --sort Sorting by download rate.
  • --save Saving to /etc/pacman.d/mirrorlist.

Garuda Linux has parallel downloads on by default (5). You can check the setting here: /etc/pacman.conf

Set Parallel Downloads

sudo nano /etc/pacman.conf

Under [options], add or adjust the ParallelDownloads parameter.

  • Recommend setting to 5.
1
2
[options]
ParallelDownloads = 5

Summary

Pacman Power-Up!

Go Pacman!
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
⠀⠀⠀⠀⣀⣤⣴⣶⣶⣶⣦⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⢿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⢀⣾⣿⣿⣿⣿⣿⣿⣿⣅⢀⣽⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀
⣼⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠛⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⠁⠀⠀⣴⣶⡄⠀⣴⣶⡄⠀⣴⣶⡄ ⣴⣶⡄ ⣴⣶⡄
⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣦⣀⠀⠙⠋⠁⠀⠙⠋⠁⠀⠙⠋⠁ ⠙⠋⠁ ⠙⠋⠁
⠸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠙⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠈⠙⠿⣿⣿⣿⣿⣿⣿⣿⠿⠋⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠉⠉⠉⠉⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀

Nice!