This document is a WORK IN PROGRESS.
This is just a quick personal cheat sheet: treat its contents with caution!
pacman
¶
pacman
is the Arch Linux package manager. It combines a simple binary package format with an
easy to use build system. The goal of pacman
is to make it possible to easily manage packages,
whether they are from the official repositories or the user's own builds.
Reference(s)
- https://wiki.archlinux.org/index.php/Pacman#Removing_packages
- https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks TODO
- https://wiki.archlinux.org/index.php/Pacman/Rosetta
- https://wiki.archlinux.org/index.php/Meta_package_and_package_group
- https://www.archlinux.org/groups/
- https://jlk.fjfi.cvut.cz/arch/manpages/man/pacman.8
- https://gitea.artixlinux.org/
Table of contents¶
Install¶
pacman-contrib
¶
[OPTIONAL]
This package contains contributed scripts and tools for pacman
systems (e.g. pactree
and
checkupdates
).
You can optionally install it to use those tools:
TODO: run $ pacman -Ql pacman pacman-contrib | grep -E 'bin/.+'
to see the full list of
pacman-contrib
tools
informant¶
[OPTIONAL]
An Arch Linux news reader designed to also be used as a pacman
hook, which prevents you from
updating if there is fresh Arch news that you have not read since the last update ran.
ancient-packages
¶
[OPTIONAL]
Config¶
See https://wiki.archlinux.org/index.php/Pacman#Configuration
See https://jlk.fjfi.cvut.cz/arch/manpages/man/pacman.conf.5
-
Edit the
pacman
config file as you wish: -
Skip a specific package from being upgrading during a system update:
-
Skip a package group from being upgrading during a system update:
Hooks¶
WIP
See https://wiki.archlinux.org/index.php/Pacman#Hooks
See https://www.archlinux.org/pacman/alpm-hooks.5.html
pacman
can run pre and post transaction hooks from the /usr/share/libalpm/hooks/
directory.
More directories can be specified with the HookDir
option in pacman.conf
, which defaults to
/etc/pacman.d/hooks
. Hook file names must be suffixed with .hook
.
E.g. pacman
post transaction hook to be notified if a transaction orphaned a package. This can be
useful for being notified when a package has been dropped from a repository, since any dropped
package will also be orphaned on a local installation, unless it was explicitly installed (see
https://wiki.archlinux.org/index.php/Pacman#Querying_package_databases):
# vi /etc/pacman.d/hooks/orphans.hook
> [Trigger]
> Operation = Remove
> Operation = Install
> Operation = Upgrade
> Type = Package
> Target = *
>
> [Action]
> Description = Be notified if a transaction orphaned a package.
> When = PostTransaction
> Exec = /usr/bin/bash -c "/usr/bin/pacman -Qtd || /usr/bin/echo '=> None found.'"
Other example: https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#List_of_installed_packages
Use¶
Installing packages¶
-
Install one or multiple specific packages:
-
Install a package as a dependency (in opposition to explicitly installed):
-
Change the "reason" of an installed package, from explicitly to dependency:
-
Change the "reason" of an installed package, from dependency to explicitly:
-
Install a package group:
-
Print what packages belong to a package group:
Maintain a list of installed packages¶
- https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#List_of_installed_packages
- https://wiki.archlinux.org/index.php/Pacman/Tips_and_tricks#Install_packages_from_a_list
Updating packages¶
- Update a package:
(NOTE: in practice, do not run
# pacman -Sy package_name
but# pacman -Syu package_name
in order to avoid dependency issues)
Updating system¶
-
Print for how long the system hasn't been updated:
$ sync_date=$(egrep 'pacman -Syu' /var/log/pacman.log | tail -1 | grep -Eo '[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}T[[:digit:]]{2}:[[:digit:]]{2}:[[:digit:]]{2}') # https://stackoverflow.com/questions/26881104/extract-date-from-a-file-name-in-unix-using-shell-scripting $ secs=$(( $(date -d now +%s) - $(date -d $sync_date +%s) )) $ days=$(echo "$secs / (60 * 60 *24)" | bc) $ echo $days
-
Read the news:
- Check the latest news here.
OR - [OPTIONAL] Check the latest news with informant (see above informant installation section and below informant usage section).
- Check the latest Arch Linux news here.
- Check the latest artix linux news here.
- Check the lastest artic linux announcements
here
OR - [OPTIONAL] Check the latest news with informant (see above informant installation section and below informant usage section).
- Check the latest artix linux news here.
- Check the lastest artic linux announcements here
- Check the latest news here.
-
[OPTIONAL] Check updates (see above
pacman-contrib
installation section and belowcheckupdates
usage section). -
Update the system:
-
See the bellow troubleshooting section if any problem is encountered.
-
# reboot
-
Remove orphans (packages that were installed as a dependency, but no other packages depend on them after the system update):
-
Remove dropped packages (packages that no longer are in the remote repositories, but still are on your local system):
Warning
# pacman -Qm
will also print manually installed packages (e.g. with AUR). To exclude packages that are (still) available on the AUR, use the ancient-packages tool (see above ancient-packages installation section and below #ancient-packages usage section).. -
[OPTIONAL] Clean package cache (see above
pacman-contrib
installation section and belowpaccache
usage section).
Removing packages¶
-
Remove a package and its dependencies which are not required by any other installed package:
-
Remove a single package, leaving all of its dependencies installed:
-
Remove a package and its dependencies (which are not required by any other installed package) and prevent the creation of it's configuration files backup (
*.pacsave
files):Info
pacman
default behavior is to backup configuration files instead of deleting them. But even when told to delete them (preventing the creation of backups)pacman
can't remove configuration files that the application created itself (e.g. "dotfiles" in the home folder).
Searching packages¶
-
Search for packages in the database, for both packages' names and descriptions containing
string1
andstring2
: -
Search for already installed packages' names and descriptions containing
string1
andstring2
: -
Search for package file names in "remote packages" (packages not from a repository stated in
pacman
's configuration files): -
Print extensive information about a given package:
-
Print extensive information about a locally installed packages:
-
Print locally installed packages containing matching a string:
-
Print the list of files installed by a package:
-
Print binary (or binaries) associated to a package, in order to find out what command(s) to use with a package:
-
Print the list of files installed by a "remote package" (package not from a repository stated in
pacman
's configuration files): -
Check the presence of the files installed by a package:
-
Search which package a file in the file system belongs to:
-
Search which "remote package" (package not from a repository stated in
pacman
's configuration files) a file belongs to: -
List all packages no longer required as dependencies (orphans):
-
List all packages explicitly installed:
-
List all packages explicitly installed:
-
List all packages explicitly installed and not required as dependencies:
Removing packages cache¶
-
Remove all the cached packages that are not currently installed and the unused sync database:
paccache
¶
From the pacman-contrib
package (see
https://wiki.archlinux.org/index.php/Pacman#Cleaning_the_package_cache and
https://jlk.fjfi.cvut.cz/arch/manpages/man/paccache.8)
-
Delete all cached versions of installed and uninstalled packages, except for the most recent 3 (by default):
-
Define how many recent versions you want to keep when deleting cached versions. E.g. to retain only one past version use:
-
Remove all cached versions of uninstalled (
-u
) packages:
makepkg
?¶
pactree
¶
From the pacman-contrib
package (see https://wiki.archlinux.org/index.php/Pacman#Pactree)
-
Print the dependency tree of a package:
-
Print the dependent tree of a package:
checkupdates
¶
From the pacman-contrib
package:
Informant¶
ancient-packages
¶
Hooks¶
Tip
/usr/share/libalpm/hooks
is for system managed hooks, and /etc/pacman.d/hooks
for user
overrides.
Mirrors¶
Reference(s)
Troubleshooting¶
-
If getting the following error when installing a package (see https://forum.artixlinux.org/index.php/topic,952.0.html):
... ... requested URL returned error: 404 ... requested URL returned error: 404 ... requested URL returned error: 404 warning: failed to retrieve some files error: failed to commit transaction (failed to retrieve some files) Errors occurred, no packages were upgraded.
Then you might have to update your mirrors located in
/etc/pacman.d/mirrorlist
(e.g. for Artix see https://gitea.artixlinux.org/packages/artix-mirrorlist/src/branch/master/mirrorlist).Then update the system with
# pacman -Syyu
(passing two-y
, or--refresh
, flags will force a refresh of all package lists even if they appear to be up to date). -
If you get this kind of error (see https://bbs.archlinux.org/viewtopic.php?id=272835):
Then this probably means your system hasn't been updated for a little while, in this case you might just have to updatearchlinux-keyring
: After that, you can try tosudo pacman -Syu
again. -
If you get this kind of error:
Then this probably means your system hasn't been updated for a little while, in this case you might just have to updateerror: package-name: signature from "..." is marginal trust :: File /path/to/package-name.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
archlinux-keyring
: After that, you can try tosudo pacman -Syu
again.
If this cheat sheet has been useful to you, then please consider leaving a star here.