$linuxjunkies
>

apt-mark(8)

Mark or unmark packages as automatically or manually installed, or hold them from upgrades.

UbuntuDebianFedoraArch

Synopsis

apt-mark {auto|manual|hold|unhold|showauto|showmanual|showhold} [PACKAGE]...

Description

apt-mark changes how apt tracks package installation state. It can mark packages as automatically installed (will be removed if no manual packages depend on them), manually installed (kept unless explicitly removed), or held (pinned at current version, ignored by upgrades).

This tool is essential for managing package dependencies and preventing unwanted upgrades. Use showauto, showmanual, and showhold to view packages in each state.

Common options

FlagWhat it does
automark packages as automatically installed
manualmark packages as manually installed
holdprevent packages from being upgraded
unholdallow held packages to be upgraded again
showautodisplay all automatically installed packages
showmanualdisplay all manually installed packages
showholddisplay all held packages
-v, --verboseshow detailed output of changes

Examples

prevent the kernel image from being upgraded automatically

apt-mark hold linux-image-generic

allow the kernel image to be upgraded again

apt-mark unhold linux-image-generic

list all packages currently held from upgrades

apt-mark showhold

mark curl and wget as automatically installed (candidates for removal)

apt-mark auto curl wget

mark python3-pip as manually installed so it won't be auto-removed

apt-mark manual python3-pip

view the first 20 automatically installed packages

apt-mark showauto | head -20

mark emacs as manual with verbose output showing the change

apt-mark -v manual emacs

count how many packages are manually installed

apt-mark showmanual | wc -l

Related commands