How to use the command 'apt-mark' (with examples)

How to use the command 'apt-mark' (with examples)

The command ‘apt-mark’ is a utility command used to change the status of installed packages on a Debian-based system. It provides various options to mark packages as automatically installed, hold a package to prevent updates, allow a package to be updated again, and show the list of manually installed or held packages.

Use case 1: Mark a package as automatically installed

Code:

sudo apt-mark auto package

Motivation: Marking a package as automatically installed is useful when you want to keep track of packages that were installed as dependencies but no longer have any dependencies. This way, you can easily remove these packages if desired.

Explanation:

  • ‘sudo’ is used to run the command with administrative privileges.
  • ‘apt-mark’ is the command itself.
  • ‘auto’ is the option used to mark the package as automatically installed.
  • ‘package’ is the name of the package to be marked.

Example Output:

package marked as auto:
  package

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

Code:

sudo apt-mark hold package

Motivation: Holding a package at its current version can be helpful when you want to prevent a specific package from being updated due to compatibility issues or other reasons. It ensures that the package remains at its current version until explicitly unheld.

Explanation:

  • ‘sudo’ is used to run the command with administrative privileges.
  • ‘apt-mark’ is the command itself.
  • ‘hold’ is the option used to hold the package.
  • ‘package’ is the name of the package to be held.

Example Output:

package set on hold:
package

Use case 3: Allow a package to be updated again

Code:

sudo apt-mark unhold package

Motivation: Allowing a package to be updated again is useful when you want to revert the hold status of a package and allow it to receive updates. This command removes the hold status and allows the package to be updated as usual.

Explanation:

  • ‘sudo’ is used to run the command with administrative privileges.
  • ‘apt-mark’ is the command itself.
  • ‘unhold’ is the option used to remove the hold status from the package.
  • ‘package’ is the name of the package to be unheld.

Example Output:

package set free, no longer on hold:
package

Use case 4: Show manually installed packages

Code:

apt-mark showmanual

Motivation: Sometimes it is necessary to identify the packages that were manually installed on a system. This command shows a list of all packages that were installed explicitly by the user, excluding packages installed as dependencies.

Explanation:

  • ‘apt-mark’ is the command itself.
  • ‘showmanual’ is the option used to display the list of manually installed packages.

Example Output:

package1
package2
package3

Use case 5: Show held packages that aren’t being updated

Code:

apt-mark showhold

Motivation: When you have multiple packages on hold status, it may be necessary to check which packages are not receiving updates. This command shows a list of packages that are currently on hold and not being updated.

Explanation:

  • ‘apt-mark’ is the command itself.
  • ‘showhold’ is the option used to display the list of held packages.

Example Output:

package1
package2
package3

Conclusion:

The ‘apt-mark’ command is a useful tool for managing the status of packages on a Debian-based system. It allows you to mark packages as automatically installed, hold packages from updates, release held packages, and view information about installed packages. Understanding and utilizing these different options can help you maintain a well-managed package system on your system.

Related Posts

How to use the command `circup` (with examples)

How to use the command `circup` (with examples)

circup is a command-line tool used for managing and updating libraries in CircuitPython projects.

Read More
How to use the command Get-ChildItem (with examples)

How to use the command Get-ChildItem (with examples)

The Get-ChildItem command in PowerShell is used to list items in a directory.

Read More
How to Use the tart Command (with examples)

How to Use the tart Command (with examples)

The tart command is a powerful tool for building, running, and managing macOS and Linux virtual machines (VMs) on Apple Silicon.

Read More