Uninstall a pkg-Installed Mac App Completely Using Its pkgutil Receipt
No uninstall for a Mac .pkg? Read its pkgutil receipt, stop launchd services, move the app's files to a holding folder and forget the receipt, with rollback.

Underlined words are defined in the KBY Lexicon. Tap or click one to see what it means.
macOS has no uninstall command for installer packages. To remove a pkg-installed Mac app completely, read its receipt with pkgutil --pkg-info and pkgutil --files, find the launch daemons and login items it registered, stop those services with launchctl bootout, move the files it owns into a root-only holding folder instead of deleting them, and only then discard the receipt with pkgutil --forget. The key constraint: the receipt only records what the package payload installed. Anything the app or its postinstall script created later is not in it, and pkgutil --forget deletes nothing on disk.
This playbook is for the Mac administrator who has to take a third-party agent, driver or app off managed Macs when the vendor ships no uninstaller, or when the uninstaller leaves pieces behind.
#How removals are usually handled today
Apple’s own advice for an app that isn’t Apple’s is to look for an Uninstall or Uninstaller app next to it, because that is the best way to delete the app together with its login items, extensions and data stored elsewhere. Failing that, drag the app to the Trash. On a single Mac that is fine. On a managed fleet it falls apart in three places.
First, dragging the app bundle away leaves its helper tools, launch daemons and preference files behind, and a daemon whose property list is still in place points at an executable that no longer exists. Second, the installer receipt stays, so the Mac still reports the package as installed and a later reinstall of the same version may not lay the files down again. Third, MDM tools often can’t help: Microsoft documents that an unmanaged macOS PKG app in Intune has no Uninstall assignment type, and that such an app is not removed from the Mac when the device is retired. The fallback is a hand-written removal script per vendor, and one built on rm -rf has no way back if it takes the wrong path.
#A better way is to let the receipt drive the removal
The installer keeps a receipt database, and pkgutil is the supported way to read it. Apple’s manual page is explicit that the files and folders where receipts are stored are subject to change, so never read or edit them directly. From the receipt you get the package’s version, volume and install location, and the list of every path its payload placed. You then add what the receipt can’t see, stop any services, move the files somewhere recoverable, and forget the receipt last.
Moving rather than deleting is the important design choice. A move within the same volume keeps ownership and permissions and can be reversed with another move. You delete the holding folder only after a quiet period in which nobody reports a broken workflow. If the app later turns out to be needed, the rollback is to put the files back, not to repackage anything.
Rendering diagram...
The diagram shows the order. The vendor’s uninstaller still comes first when one exists; the receipt steps then confirm it really removed everything and clean up the record it may have left.
#Step by step on a test Mac
Run this on a test Mac that has the same version of the app as the fleet before you script it. Each step says what you should see and when to stop.
Find the package identifier. Run
pkgutil --pkgs='com.example.*', using the vendor’s reverse DNS prefix. The equals sign is required; without it the search string is ignored and every installed package ID is printed. Quote the pattern so the shell doesn’t expand it. Vendors often split one product across several packages, so expect more than one line. Stop if nothing matches: the app was not installed from a package, and this method doesn’t apply.Read the receipt. Run
pkgutil --pkg-info com.example.app. It printspackage-id,version,volume,locationandinstall-time. Note the volume and location: the paths thatpkgutil --filesprints are relative to the package’s install location, which is usually, but not always, the root of the volume. An empty location means paths start at the volume root.List what the payload installed. Run
pkgutil --files com.example.app. You will see shared parent folders as well as the package’s own items, for exampleusr,usr/local,usr/local/binand thenusr/local/bin/tool. Add--only-filesor--only-dirsto split them. From this list, pick only the top-level items that belong to the product: its app bundle, its helper tools, its launchd property lists. Never pick a parent folder such asApplications,Libraryorusr/local/bin.Check each item really belongs to this package alone. Run
pkgutil --file-infoon each path you picked. It prints thepkgidthat installed it, and if several packages placed the same file you get a list. If another package ID appears, leave the item where it is. If no package information appears at all, the file was copied, moved or created by a script rather than the payload.Find what the receipt can’t see. An app or tool might create daemons, agents, preferences and configuration files that were never part of the payload and are not tracked in the receipt. Run
sudo sfltool dumpbtm, which Apple documents as printing the current status of login and background items, and look for entries from the vendor. On macOS 13 or later, System Settings > General > Login Items also lists items registered through Apple’s background task framework. For a daemon,sudo launchctl print system/com.example.helpershows where its definition came from on disk and its current state. Add anything you find to your list, and check it withpkgutil --file-infothe same way.Run the vendor’s uninstaller if there is one. Then repeat steps 2 to 5. Whatever is still listed is what the uninstaller left behind.
Stop the services. Daemons and agents have to be unloaded and quit before their files go, as Armin Briegel’s guide to inspecting packages on Scripting OS X points out. Quit the app, then for each system daemon run
sudo launchctl bootout system/com.example.helper. For a per-user agent the domain target isgui/<uid>, for examplegui/501/com.example.agent. Stop condition: if bootout reports an error for a service you expected to be loaded, don’t move its files yet; find out what is holding it.Move the files to a holding folder. The script below is a dry run until you set
APPLY=1. It refuses any item another package also owns and recreates each item’s path under a root-only folder, so every move can be reversed exactly.Keep a copy of the receipt, then forget it. Run
pkgutil --export-plist com.example.app > ~/com.example.app-receipt.plistto keep the full receipt record, thensudo pkgutil --forget com.example.app. This discards the receipt data and doesn’t touch installed files, which is why it comes last. Apple warns against using--forgetfrom inside an installer script to paper over a broken package design; here it is used on its own, after the files have gone.
Following along? Tap a step’s number to tick it off.
1#!/bin/zsh
2# Dry run by default: prints what it would move. Set APPLY=1 to move.
3PKGID="com.example.app"
4BASE="/" # volume plus location from pkgutil --pkg-info
5HOLD="/private/var/uninstall-holding/${PKGID}-$(date +%Y%m%d)"
6APPLY=0
7ITEMS=(
8 "Applications/Example.app"
9 "Library/LaunchDaemons/com.example.helper.plist"
10 "Library/PrivilegedHelperTools/com.example.helper"
11)
12(( APPLY )) && mkdir -m 700 -p "$HOLD"
13for rel in "${ITEMS[@]}"; do
14 src="${BASE%/}/$rel"
15 [[ -e "$src" ]] || { echo "not present: $src"; continue; }
16 owners=$(pkgutil --file-info "$src" | awk '/^pkgid:/{print $2}' | sort -u)
17 if [[ -n "$owners" && "$owners" != "$PKGID" ]]; then
18 echo "SKIP, also owned by: $owners $src"; continue
19 fi
20 echo "move: $src -> $HOLD/$rel (receipt: ${owners:-none})"
21 if (( APPLY )); then
22 mkdir -p "$HOLD/${rel:h}" && mv "$src" "$HOLD/$rel"
23 fi
24doneRun the script with sudo from your MDM’s script runner only after it has passed on a test Mac in dry-run mode. If a daemon is defined in /Library/LaunchDaemons, the article on running a root script at boot with a macOS LaunchDaemon explains the plist layout and the bootstrap and bootout domain targets in more detail.

#Who can run the removal
Every step that changes state needs root, because the installer laid the files down as root. Keep that power narrow:
- Only the MDM’s script runner, or an administrator on a test Mac, runs the move and forget steps. Users with local admin rights shouldn’t get a self-service button for it.
- Each script names one package ID and an explicit list of items. A script that removes everything
pkgutil --filesprints is not acceptable, because that list includes shared system folders. - The holding folder is created with mode 700 under
/private/var, so only root can read the moved files. Moved helper tools and daemons are still the vendor’s signed code; keeping them out of reach of standard users matters. - If the product is a security agent, endpoint protection or anything with a system extension, stop and use the vendor’s documented removal process. Removing those by hand can leave a Mac unprotected or in a state the vendor won’t support.
#Verify the Mac is clean
Check the result from the same read-only commands you started with:
pkgutil --pkgs='com.example.*'no longer lists the package ID you forgot.pkgutil --file-infoon the old app path reports only the path and volume, with nopkgid, or the path no longer exists.sudo launchctl print system/com.example.helperno longer finds the service.sudo sfltool dumpbtmno longer lists the vendor’s background items, and they are gone from System Settings > General > Login Items.- The holding folder contains every item the dry run listed, at the same relative paths.
Collect these as the script’s output in your MDM, so each Mac’s result is recorded rather than assumed.
#What goes wrong with receipt-based removals
The most damaging mistake is treating the --files list as a delete list. It contains directories such as Applications and usr/local, and a reverse-order rm -rf over it can remove folders other software depends on. Pick top-level items by hand, once, and put them in the script.
The second is ignoring the install location. If --pkg-info shows a location other than the volume root, every relative path has to be joined to it. Getting this wrong means the script finds nothing, or worse, finds something else at the same relative path.
Third, files created after install aren’t in the receipt. Caches, preferences in each user’s Library and items written by a postinstall script won’t appear in --files. That is why sfltool dumpbtm and the vendor’s own documentation matter. Per-user data in home folders is the user’s; leave it unless the vendor says otherwise.
Fourth, forgetting the receipt first. If you run --forget before moving the files, you lose the list that tells you what to move. If you move the files and never forget the receipt, the Mac still claims the package is installed, and reinstalling the same version may not put the files back. The receipt should be forgotten once the removal works, so a future reinstallation runs as a fresh install.
Finally, an app that is running or has a daemon still loaded. Moving the bundle of a running app or a loaded daemon’s binary leaves a process with nothing on disk, and launchd may keep trying to start it. The playbook on update failures caused by apps that are still in use covers detecting a running app before you touch its bundle.

#Roll back a removal
Because nothing was deleted, rollback is the removal in reverse
- Move each item from
/private/var/uninstall-holding/<package>-<date>/back to the same relative path under the install base. A move on the same volume keeps ownership and permissions. - Load each daemon again with
sudo launchctl bootstrap system /Library/LaunchDaemons/com.example.helper.plist, and confirm it withlaunchctl print. - Reinstall the same signed package version, which writes a fresh receipt. Once a receipt has been forgotten, the installer treats the package as a new installation, so the payload is laid down again. Keep the receipt plist you exported to compare versions.
- Check that the app opens and that its login items reappear. If they need approval again, the playbook on automating background task approval shows how to approve them through a profile instead of the user.
Once the holding period is over and no rollback has been needed, deleting the holding folder is the only irreversible step. Make it a separate, deliberate decision rather than part of the removal script.
#What to track
Measure the removal by what the Macs report, not by how many scripts ran. Useful counts from your MDM’s inventory or script output:
- Macs where
pkgutil --pkgsstill returns the package ID after the removal ran. - Macs where the dry run skipped an item because another package owns it. Each one needs a decision before the next run.
- Macs where
sfltool dumpbtmstill shows the vendor’s background items. - Rollbacks requested during the holding period, and why.
Review those numbers when each removal wave finishes, and again before the holding folders are deleted. A second pass that finds no leftovers is the sign the item list is complete.
#Before you roll it out to the fleet
- The vendor’s uninstaller, if any, has been run on a test Mac and its leftovers listed.
- The package IDs, install base and top-level items are written into the script by hand.
- Every item passed the
pkgutil --file-infoownership check. - Launch daemons and agents are booted out before their files move.
- The dry run output matches what you expect on at least one test Mac.
- The receipt is exported before it is forgotten.
- Rollback has been tested once: files moved back, services bootstrapped, package reinstalled.
- Security agents and system extensions are excluded and handled through the vendor’s process.
- The holding period is agreed, and deleting the holding folders is scheduled as its own change.
If the app was deployed by your MDM and is still assigned, remove the assignment first, or the next check-in may install it again. For an app that reports as installed but is missing after deployment, the reverse problem, see why a pkg shows success in MDM but the app is missing.
About this page
Credited to
Dates
Published
Sources
Corrections
No corrections are listed for this page. Some review sweeps corrected pages without naming each one; those are in the corrections log.
Recommended reading
More from KBY that goes with this article.
Related articles
Application Lifecycle
macOS pkg Installed by MDM Shows Success but App Is Missing
Diagnose a macOS pkg that MDM reports as installed while the app is missing, using install.log and pkgutil receipts, then redeploy safely.
ReadPlatforms and devices
A TPM-Only BitLocker Setup Does Not Stop the Unpatched Windows FastUnlock Bypass
A researcher's FastUnlock technique lets someone holding a locked Windows PC run programs without signing in. Microsoft has issued no fix and no attacks are reported. Why TPM-only BitLocker does not help, and who should add a startup PIN.
ReadConsumer tech
Tidal Will Ban Fully AI-Generated Music on 9 December: What It Means for Listeners
Tidal says it will delete millions of fully AI-made tracks on 9 December and refuse new ones. What changes for your playlists, what stays, and how other streaming services compare.
ReadDiscover more
Ops Playbook
Lexicon Definitions
Was this useful?
Reports go to the site owner and are used to correct pages. Corrections are listed at /corrections.
Operate smarter, with fewer recurring tickets.
Receive new operational playbooks, incident-prevention guidance, automation scripts and recovery runbooks.


Comments
Add a thoughtful note on Uninstall a pkg-Installed Mac App Completely Using Its pkgutil Receipt. Comments are checked for spam and held for moderation before appearing.