How To Use apt-mark Command In Linux?

How To Use apt-mark Command In Linux?

 

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.

Previous [ubuntu] Can't connect USB drive to VM
Next How To Find IP Address In Linux Using Terminal?
 

About author

You might also like

Linux Topics 0 Comments

How to check if a disk uses GPT or MBR in Linux?

In a computer, MBR and GPT are two ways of storing the partitioning information on a disk. The MBR is a legacy while GPT is a newer disk partitioning style

Linux Topics 0 Comments

How To Convert A Disk From GPT To MBR On Linux?

The firmware interface is a way by which firmware interacts with the operating system. The BIOS is the usual firmware interface while UEFI is the newer one that has some

Linux Topics 0 Comments

How To Create An ISO Image In Linux Using Terminal?

This post was last updated on August 1st, 2020 at 10:18 pmIso image files are distributed as a single downloadable file for bootable OS, games, etc. It is important to

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply