On different distributions of Linux that use apt as the default package manager, apt-mark can be used to show, set, unset various settings of a package.
The apt-mark can be used to perform various advanced administrative tasks such as it can mark a package as it is being automatically or manually installed.
It can also be used to change the dpkg selection states such as hold, install, deinstall, or purge a package. In this article, we will see more about the apt-mark and its usage with examples.
Different mark on a package
The apt-mark can be used to change various settings of a software package on a system. These settings are also known as “marks” and fall into three given categories –
auto
When you request to install a package some other packages also get downloaded and installed to satisfy the dependencies of that package. The packages that get downloaded when you request to install a package will be marked as automatically installed packages.
manual
The requested package will be marked as a manually installed package. The apt and aptitude will start suggesting to remove automatically installed packages when you remove this package.
hold
No operations can be performed on a package if it is marked hold. The package can not be installed, removed, or upgraded unless you remove the hold mark.
Package selection states
A package in Linux can have the following selection states –
install – The package is marked for installation.
deinstall – The package is marked for removal.
purge – The package is marked for removal along with the dependencies
hold – The package can not be installed, removed, or upgraded until the hold mark is removed.
Examples of using apt-mark
A few examples and usages of apt-mark command in Linux is given below –
Disable or lock a package
The apt-mark command can be used with option hold to prevent a package from installation, removal, or up-gradation. For example to mark the package nginx-core
hold, use the following command in your terminal –
apt-mark hold nginx-core
To make this package available for installation, removal, or up-gradation, use –
apt-mark unhold nginx-core
Display the list of manually installed packages
To display the list of manually installed packages on a system, use the following command –
apt-mark showmanual
Display the list of automatically installed package packages
It is similar to the showmanaul option but it prints the list of automatically installed packages on a system, Now to display the list of automatically installed packages use the following command in your system –
apt-mark showauto
Conclusion
Ok, that’s all for now. I hope this gives you an understanding of how to manipulate packages using the apt-mark command in Linux. Now if you have questions on this you can leave in the comments below.