pkgutil - macOS

## Overview

pkgutil is a command-line tool for managing packages on macOS. It can be used to install, upgrade, remove, and list packages, as well as view and modify package properties.

## Syntax

pkgutil [options] command [--args]

## Options/Flags

  • -a, –all: Show all packages, including hidden ones.
  • -g, –global: Operate on the global package database.
  • -p, –pkgroot: Specify the root directory of the package database.
  • -v, –verbose: Print verbose output.

## Commands

  • –copy: Copy a package to a different location.
  • –create: Create a new package.
  • –delete: Delete a package.
  • –extract: Extract the contents of a package.
  • –install: Install a package.
  • –info: Display information about a package.
  • –list: List all packages.
  • –move: Move a package to a different location.
  • –sign: Sign a package.
  • –upgrade: Upgrade a package.
  • –verify: Verify the signature of a package.

## Examples

  • List all installed packages:
pkgutil --all list
  • Install a package from a file:
pkgutil --install /path/to/package.pkg
  • Remove a package:
pkgutil --delete com.example.package
  • Upgrade a package:
pkgutil --upgrade com.example.package
  • Extract the contents of a package:
pkgutil --extract /path/to/package.pkg /path/to/extract

## Common Issues

  • Permission denied: Make sure you have sufficient permissions to perform the desired operation.
  • Package not found: Check that the package exists and is in the correct location.
  • Invalid syntax: Double-check that you are using the correct syntax for the command and options.

## Integration

pkgutil can be used in conjunction with other macOS commands for advanced package management tasks. For example:

find /Applications -exec pkgutil --info {} \;

This command would print information about all packages installed in the Applications folder.

## Related Commands

  • install_pkg – A lower-level command for installing packages.
  • spctl – A command for managing the System Policy Configuration.
  • pkgsh – A graphical user interface for managing packages.