How to use the command pkgutil (with examples)

How to use the command pkgutil (with examples)

  • Osx
  • December 25, 2023

The pkgutil command is used to query and manipulate Mac OS X Installer packages and receipts. It provides various functionalities to list package IDs, verify package signatures, list files for installed packages, and extract contents of package files.

Use case 1: List package IDs for all installed packages

Code:

pkgutil --pkgs

Motivation:

  • This use case is useful when you want to get a list of all the package IDs for the installed packages on your Mac.
  • It can be helpful for troubleshooting, automation, or simply knowing which packages are currently installed.

Explanation:

  • --pkgs is an option used to list the package IDs for all the installed packages.
  • No arguments are provided with this option.

Example output:

com.apple.pkg.AirPortUtility5.6.1
com.apple.pkg.BSFeedFramework
com.apple.pkg.CoreFP
...

Use case 2: Verify cryptographic signatures of a package file

Code:

pkgutil --check-signature path/to/filename.pkg

Motivation:

  • This use case is useful when you want to verify the cryptographic signature of a specific package file.
  • Verifying the signature ensures that the package file has not been tampered with or modified since it was signed.

Explanation:

  • --check-signature is an option used to verify the cryptographic signature of a package file.
  • path/to/filename.pkg represents the path to the package file you want to verify.
  • Replace path/to/filename.pkg with the actual path and filename of the package file.

Example output:

Package "filename.pkg":
   Status: signed by a certificate trusted by Mac OS X
   Certificate Chain:
    1. Developer ID Installer: Example Developer (ABCDEF123456)
...

Use case 3: List all the files for an installed package given its ID

Code:

pkgutil --files com.microsoft.Word

Motivation:

  • This use case is useful when you want to get a list of all the files associated with a specific installed package.
  • It can help you understand what files are included in a package and where they are installed on your system.

Explanation:

  • --files is an option used to list all the files for an installed package.
  • com.microsoft.Word represents the package ID for Microsoft Word. Replace it with the actual package ID you want to get the files for.

Example output:

Library/Fonts/AGOARD.TTF
Library/Fonts/AHARONI.TTF
Library/Fonts/AHARONIB.TTF
...

Use case 4: Extract the contents of a package file into a directory

Code:

pkgutil --expand-full path/to/filename.pkg path/to/directory

Motivation:

  • This use case is useful when you want to extract the contents of a package file into a specific directory.
  • You might need to examine the contents of a package file or extract specific files from it for further use.

Explanation:

  • --expand-full is an option used to extract the contents of a package file into a directory.
  • path/to/filename.pkg represents the path to the package file you want to extract.
  • path/to/directory represents the path to the directory where the contents of the package file will be extracted.
  • Replace path/to/filename.pkg and path/to/directory with the actual paths and filenames/directory names you want to use.

Example output:

Extracted package contents to: /path/to/directory

Conclusion:

The pkgutil command provides a versatile set of options for querying and manipulating Mac OS X Installer packages and receipts. These use cases cover common scenarios such as listing package IDs, verifying package signatures, listing installed package files, and extracting package contents. Incorporating these examples into your toolkit will help you effectively manage packages on your Mac.

Related Posts

Using the ftype command (with examples)

Using the ftype command (with examples)

1: Display a list of all file types Code: ftype Motivation: When working with file extensions and associations in Windows, it can be useful to have a comprehensive list of all file types currently registered on the system.

Read More
How to use the command 'eopkg' (with examples)

How to use the command 'eopkg' (with examples)

The eopkg command is a package manager for Solus. It allows users to install, update, and search for packages on the Solus operating system.

Read More
How to use the command `lpq` (with examples)

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

The lpq command is used to show the printer queue status.

Read More