apt-mark Command Examples in Linux

apt-mark is a command-line utility that is part of the apt package manager in Linux distributions that use the Debian package management system, such as Ubuntu and Debian itself. It allows you to mark packages as manually installed or automatically installed, and to list the packages that are currently marked as manually installed.

The apt package manager is responsible for installing, updating, and removing packages on a Debian-based system. When you install a package with apt, it is marked as automatically installed. This means that if you later decide to remove the package with apt, the package manager will also remove any other packages that were installed as dependencies of that package, even if they are no longer needed by any other installed packages.

The apt-mark command can be used to override this behavior and mark a package as manually installed. This can be useful if you have installed a package that is not available in the default repositories, or if you have removed a package that was installed as a dependency of another package but you want to keep it on the system. When a package is marked as manually installed, apt will not automatically remove it when you remove the package that depends on it.

apt-mark Command Examples

1. Mark a package as automatically installed:

# apt-mark auto {{package_name}}

2. Hold a package at its current version and prevent updates to it:

# apt-mark hold {{package_name}}

3. Allow a package to be updated again:

# apt-mark unhold {{package_name}}

4. Show manually installed packages:

# apt-mark showmanual

5. Show held packages that aren’t being updated:

# apt-mark showhold

6. To mark a package as manually installed:

# apt-mark markmanual package-name

7. To check if a particular package is marked as manually installed:

# apt-mark showmanual package-name
Note: Note that apt-mark only works with installed packages. If you try to mark a package that is not installed as manually installed, it will not have any effect.
Related Post