paclock
Control keyboard lock keys
TLDR
Lock the database
Write the lock file path to stdout (without locking the database)
Unlock the database
Display help
Display version
SYNOPSIS
paclock [-fhuq] [-d directory]
PARAMETERS
-d, --directory <dir>
Use alternate directory instead of /var/lib/pacman.
-f, --force
Forcibly remove all lock files in directory.
-h, --help
Print usage help and exit.
-q, --quiet
Suppress all non-error output.
-u, --unlock
Remove existing lock file if present.
DESCRIPTION
Paclock is a utility bundled with the pacman package manager on Arch Linux and derivatives. It manages exclusive locks on the pacman database directory (default: /var/lib/pacman) to avoid simultaneous modifications that could corrupt the package database.
By default, paclock acquires and holds an exclusive lock on db.lck. If locked by another process, it waits indefinitely until released or interrupted (e.g., Ctrl+C). This ensures safe concurrency during package installations, updates, or removals.
Pacman invokes paclock automatically, but it can be used standalone in scripts to check or enforce locks before operations. Options allow unlocking stale locks or forcing removal, though the latter risks data loss if processes are active.
Reliant on filesystem locking (e.g., fcntl or flock), it works on most Linux filesystems but may behave differently on network mounts.
CAVEATS
-f can corrupt database if pacman is running; verify with ps aux | grep pacman. Arch Linux-specific; ineffective on unsupported filesystems.
DEFAULT BEHAVIOR
Acquires/holds lock indefinitely; waits if locked; Ctrl+C to release.
EXAMPLES
paclock -q (quiet lock).
paclock -u (unlock).
paclock -f (force clear locks).
HISTORY
Developed by Arch Linux team as part of pacman since ~2006 (pacman 3.x era) for safe concurrency; maintained in pacman-contrib or core pacman package.
SEE ALSO
pacman(8)


