Cyberithub

10 apt-mark command examples for Package administration in Linux

Advertisements

In this article, we will go through 10 apt-mark command examples for package administration in Linux. apt-mark can be used as a unified front-end to set various settings for a package, such as marking a package as being automatically/manually installed or changing dpkg selections such as hold, install, deinstall and purge which are respected e.g. by apt-get dselect-upgrade or aptitude. You will find this utility available by default in latest Ubuntu/Debian based systems. We will see some of the real world examples of apt-mark command in below section. More about apt-mark.

10 apt-mark command examples for Package administration in Linux

apt-mark command examples for Package administration in Linux

Also Read: How to Install aptitude package on Ubuntu/Debian with Example

Example 1: How to Check apt-mark command version

If you want to check apt-mark command version then you need to use apt-mark --version command as shown below. As you can see current installed version is 2.2.4.

root@debian:~# apt-mark --version
apt 2.2.4 (amd64)

 

Example 2: How to List all automatically installed packages

If you want to check all automatically installed packages then you need to use apt-mark showauto command as shown below.

root@debian:~# apt-mark showauto
accountsservice
acl
adwaita-icon-theme
aisleriot
alsa-topology-conf
alsa-ucm-conf
alsa-utils
anacron
apache2-bin
apg
apparmor
appstream
apt-config-icons
aptitude-common

 

Example 3: How to List all manually installed packages

If you want to check all manually installed packages then you need to use apt-mark showmanual command as shown below.

root@debian:~# apt-mark showmanual
adduser
apt
apt-listchanges
apt-utils
aptitude
base-files
base-passwd
bash
bash-completion
bind9-dnsutils
bind9-host
bsdutils
busybox

 

Example 4: How to Set hold on a Package

If you want to prohibit any specific package from update then you can set hold on that package using apt-mark hold <package_name> syntax. In this example we are preventing wget package from any update by using apt-mark hold wget command as shown below.

root@debian:~# apt-mark hold wget
wget set on hold.

 

Example 5: How to Remove a Package from Hold

You can also remove the hold from a package by using apt-mark unhold <package-name> syntax. In this example we are removing the hold from wget package by using apt-mark unhold wget command as shown below.

root@debian:~# apt-mark unhold wget
Canceled hold on wget.

 

Example 6: How to Show all the Packages Kept in Hold

If you want to see all the packages which has hold set on it then you need to use apt-mark showhold command as shown below. As you can see there is only one package which has hold set on it.

root@debian:~# apt-mark showhold
wget

 

Example 7: How to Set a Package to Automatically Installed

If you want to set a package to automatically installed then you need to use apt-mark auto <package-name> syntax. In this example, we are setting wget package to automatically installed by using apt-mark auto wget command as shown below.

root@debian:~# apt-mark auto wget
wget set to automatically installed.

 

Example 8: How to Set a Package to Manually Installed

Similarly, if you want to set a package to manually installed then you need to use apt-mark manual <package_name> syntax. In this example, we are setting wget package to manually installed using apt-mark manual wget command as shown below.

root@debian:~# apt-mark manual wget
wget set to manually installed.

 

Example 9: How to Check all the options available with apt-mark command

If you want to check all the options available with apt-mark command then you need to use apt-mark --help command as shown below.

root@debian:~# apt-mark --help
apt 2.2.4 (amd64)
Usage: apt-mark [options] {auto|manual} pkg1 [pkg2 ...]

apt-mark is a simple command line interface for marking packages
as manually or automatically installed. It can also be used to
manipulate the dpkg(1) selection states of packages, and to list
all packages with or without a certain marking.

Most used commands:
auto - Mark the given packages as automatically installed
manual - Mark the given packages as manually installed
minimize-manual - Mark all dependencies of meta packages as automatically installed.
hold - Mark a package as held back
unhold - Unset a package set as held back
showauto - Print the list of automatically installed packages
showmanual - Print the list of manually installed packages
showhold - Print the list of packages on hold

 

Example 10: How to Check Man Page of apt-mark command

If you want to check the man page of apt-mark command then you need to use man apt-mark command as shown below.

root@debian:~# man apt-mark
APT-MARK(8) APT APT-MARK(8)

NAME
apt-mark - show, set and unset various settings for a package

SYNOPSIS
apt-mark {-f=filename | {auto | manual} pkg... | {showauto | showmanual} [pkg...] } | {-v | --version} | {-h | --help}

apt-mark {hold | unhold | install | remove | purge} pkg... | {showhold | showinstall | showremove | showpurge} [pkg...]

DESCRIPTION
apt-mark can be used as a unified front-end to set various settings for a package, such as marking a package as being automatically/manually
installed or changing dpkg selections such as hold, install, deinstall and purge which are respected e.g. by apt-get dselect-upgrade or aptitude.

Leave a Comment