Linux apt-mark command
On Linux operating systems that use the APT package management system, the apt-mark command performs advanced administrative tasks on installed packages. It helps repair a damaged or corrupted local package repository.
Description
The apt-mark tool can change the settings of software packages used by APT.
These settings, called "marks", fall into three general categories:
- "Automatically", or "manually", installed.
- "Hold" (held back). Held back packages cannot be installed, removed, purged, or upgraded unless the hold mark is removed.
- Selection states.
"Auto" and "manual" marks
aptitude, the package is marked as manually installed: you explicitly installed it, so the system will not remove it unless you ask for it to be removed.
On the other hand, some packages are installed because they're dependencies of a package you manually installed. APT marks these dependencies as automatically installed. These packages are marked for auto-removal if they are no longer needed, for instance with apt-get autoremove.
Using apt-mark, you can change how a package is marked, protecting it from (or making it eligible for) auto-removal.
"Hold" marks
If a package is marked "hold", it is held back: The package cannot be installed, upgraded, or removed until the hold mark is removed.
Selection states
The selection state of a package can be:
- install: this package is marked for installation.
- deinstall (remove): this package is marked for removal.
- purge: this package, and all its configuration files, are marked for removal.
- hold: this package cannot be installed, upgraded, removed, or purged.
Selection states are used internally by APT and dpkg. For more information about setting selection states, see dpkg --set-selections.
Syntax
apt-mark {-c=location} | {-f=filename} | {auto | manual} pkg... | {showauto | showmanual} [pkg...] } | {-v | --version} | {-h | --help} | {hold | unhold | install | remove | purge} pkg... | {showhold | showinstall | showremove | showpurge} [pkg...]
Commands
auto | Mark a package as automatically installed. This marks the package to be removed when there are no manually-installed packages which depend on it. |
manual | Mark a package as manually installed. This prevents the package from being automatically removed when no other manually-installed packages depend on it. |
showauto | Print a list of all packages marked as automatically installed. |
showmanual | Print a list of all packages marked as manually installed. |
hold | Mark a package as "hold" (held back). |
unhold | Remove a "hold" mark on a package. |
install | Set the selection state of a package to "install". |
remove | Set the selection state of a package to "deinstall" (remove). |
purge | Set the selection state of a package to "purge". |
showhold | Show which packages are marked "hold". |
showinstall | Show which packages are marked "install". This includes currently-installed packages. |
showremove | Show which packages are marked "remove". |
showpurge | Show which packages are marked "purge". |
Options
-f=filename, --file=filename |
Read, or write, package statistics to filename. |
-v, --version |
Show version information for apt-mark. |
-c=location, --config-file=location |
Specify a configuration file or directory to be used. You can also specify a configuration file or directory with the environment variable APT_CONFIG. The default configuration file or directory is /etc/apt/apt.conf or /etc/apt/apt.conf.d. |
-o, --option |
Set a configuration option. Can be used (multiple times) to set individual options found in the configuration file or directory. |
-h, --help |
Display a brief listing of commands and options. |
Examples
sudo apt-mark auto ruby
Mark the software package ruby as automatically installed. When no other software packages depend on it, ruby will be eligible for auto-removal.
sudo apt-mark manual ruby
Mark the software package ruby as manually installed. It is not eligible for auto-removal, even if no other packages depend on it.
apt-mark showinstall
Show all packages with a selection state of "install".
sudo apt-mark hold emacs
Mark the package emacs as held back. It cannot be installed, upgraded, removed, or purged.
sudo apt-mark unhold emacs
Cancel the hold on emacs.
Related commands
apt — A unified APT front end for the command line.
apt-cache — Get information about installed and available APT software packages.
apt-get — Download and install APT software packages.
aptitude — An enhanced APT front end for the terminal.
dpkg — Install, remove, and maintain Debian software packages.