ALPM-HOOKS(5)
π ALPM-HOOKS π
okay bestie, so this is the manual page for alpm-hooks, aka the alpm hook file format. yeah. the lil config files that make pacman do stuff before and after it touches your packages. it's giving automation. it's giving β¨controlβ¨. let's get into it π«Ά
β¨ SYNOPSIS β¨
[Trigger] (Required, Repeatable)
Operation = Install|Upgrade|Remove (Required, Repeatable)
Type = Path|Package (Required)
Target = <Path|PkgName> (Required, Repeatable)
[Action] (Required)
Description = ... (Optional)
When = PreTransaction|PostTransaction (Required)
Exec = <Command> (Required)
Depends = <PkgName> (Optional)
AbortOnFail (Optional, PreTransaction only)
NeedsTargets (Optional)
πΈ DESCRIPTION πΈ
so libalpm is out here giving you the ability to specify hooks that run before or after transactions, based on which packages and/or files are getting modified. and a hook is literally just one [Action] section (that's the thing it's gonna do) plus one or more [Trigger] sections (that's the "when should I even care" part). simple. iconic.
hooks get read from files in the system hook directory /usr/share/libalpm/hooks, plus any extra custom directories you set in pacman.conf(5) (the default extra one is /etc/pacman.d/hooks). and the file names must end in ".hook" β no suffix, no service, no hook, sorry. π
they run in alphabetical order by file name, and the ordering ignores the suffix. so 10-something.hook goes before 20-other.hook, obviously, but like, alphabetically. keep up π
π¦ TRIGGERS π¦
a hook MUST have at least one [Trigger] section, bestie, and that's the thing that decides which transactions make the hook go. if you define multiple trigger sections, the hook runs if the transaction matches any of them. yes, ANY. it's giving generous. β¨
Operation = Install|Upgrade|Removeβ picks what kind of operation to match your targets against. you can specify this multiple times, go off. heads up tho: installations count as an upgrade if the package or file is already on the system, regardless of whether the new package version is actually greater than the currently installed one. like, don't even worry about version comparison, that's not the vibe here. and forPathtriggers, this is true even if the file changes ownership from one package to another. Required. πType = Path|Packageβ chooses whether your targets get matched against transaction packages or files. peepCAVEATSfor the special notes aboutPathtriggers, there's lore. alsoFileis a deprecated alias forPathand will be removed in a future release, so likeβ¦ don't. Required.Target = <path|package>β the path or package name to match against the active transaction. paths refer to the files in the package archive, so do not include the installation root in the path, okay? shell-style glob patterns are allowed π. you can also invert matches by prepending a target with an exclamation mark!. may be specified multiple times, and subsequent matches override previous ones (last one wins, main character energy). Required.
π ACTIONS π
Description = ...β an optional lil description of what the hook is doing, for use in front-end output. it's the caption. the little blurb. optional.Exec = <command>β the command to run. command arguments get split on whitespace. values that contain whitespace should be enclosed in quotes. Required. no cap.When = PreTransaction|PostTransactionβ when to run the hook. Required. pick a lane.Depends = <package>β packages that must be installed for the hook to run. may be specified multiple times. it's the friend group that has to show up before the party starts.AbortOnFailβ causes the transaction to be aborted if the hook exits non-zero. β οΈ only applies toPreTransactionhooks. so if you're in the post-game, this does nothing for you.NeedsTargetsβ causes the list of matched trigger targets to be passed to the running hook on stdin. it's giving "here, hold my list" π
π OVERRIDING HOOKS π
hooks can be overridden by placing a file with the same name in a higher priority hook directory. and you can disable a hook entirely by overriding it with a symlink to /dev/null. yeah, just yeet it into the void. π
β EXAMPLES β
# Force disks to sync to reduce the risk of data corruption
[Trigger]
Operation = Install
Operation = Upgrade
Operation = Remove
Type = Package
Target = *
[Action]
Depends = coreutils
When = PostTransaction
Exec = /usr/bin/sync
okay look at her go. she syncs the disks. she reduces the risk of data corruption. she's everything. π₯
π CAVEATS π
there are situations when path triggers may act in unexpected ways, bestie, and you need to know about them:
- hooks are triggered using the file list of the installed, upgraded, or removed package.
- when installing or upgrading a file that is extracted with a
.pacnewextension, the original file name is used in triggering the hook. - when removing a package, all files owned by that package can trigger a hook, whether or not they were actually present on the file system before package removal. like, they don't have to exist. the ghost of the file triggers the hook. π
β οΈ PostTransaction hooks will not run if the transaction fails to complete for any reason. so if the transaction flops, the post-hook doesn't even get out of bed. periodt.
see the pacman website at https://archlinux.org/pacman/ for current info on pacman and its related tools. π«Ά
π BUGS π
bugs?? you must be kidding, there are no bugs in this software. π€¨ but if we happen to be wrong (we're not, but like, if), please report them to the issue tracker at https://gitlab.archlinux.org/pacman/pacman/-/issues with specific information such as your command-line, the nature of the bug, and even the package database if it helps. give them everything, they want the receipts. π§Ύ
π AUTHORS π
Current maintainers:
- Allan McRae
<allan@archlinux.org> - Andrew Gregory
<andrew.gregory.8@gmail.com> - Morgan Adamiec
<morganamilo@archlinux.org>
Past major contributors:
- Judd Vinet
<jvinet@zeroflux.org> - Aurelien Foret
<aurelien@archlinux.org> - Aaron Griffin
<aaron@archlinux.org> - Dan McGee
<dan@archlinux.org> - Xavier Chantry
<shiningxc@gmail.com> - Nagy Gabor
<ngaba@bibl.u-szeged.hu> - Dave Reisner
<dreisner@archlinux.org> - Eli Schwartz
<eschwartz@archlinux.org>
for additional contributors, use git shortlog -s on the pacman.git repository. the whole squad is in the credits fr fr π
and that's the whole page, bestie!! this was Pacman 7.1.0, dated 2026-10-15, section 5 of the manual. slay, go write some hooks, and remember: alphabetical order, no suffix in the ordering, and don't use File, it's deprecated. mwah π
β¨π¦
π¦ where this page comes from
- arch rolling: pacman 7.1.0.r9.g54d9411-3 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms