Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

macos - Uninstall packages in Mac OS X

How can you completely uninstall (remove files that belong to a certain package) in Mac OS X? Can this be done using a command in the terminal?

I have installed a .pkg package on my Mac and I am wondering as to how I can uninstall the entire package without using a third party application such as UninstallPKG?

I am wondering whether uninstalling .dmg files also require third party applications or is it possible to uninstall them entering a command in the terminal?

question from:https://stackoverflow.com/questions/25925752/uninstall-packages-in-mac-os-x

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Use this command in terminal for check the list of package and uninstalled your files.

$ pkgutil --pkgs # list all installed packages

Once you've uninstalled the files, you can remove the receipt with:

$ sudo pkgutil --forget the-package-name.pkg

After visually inspecting the list of files you can do something like:

$ pkgutil --pkg-info the-package-name.pkg # check the location
$ cd / # assuming the package is rooted at /...
$ pkgutil --only-files --files the-package-name.pkg | tr '
' '' | xargs -n 1 -0 sudo rm -i

Be careful of this last step. The list of directories output by pkgutil --files can include important shared directories like usr, which you don't want to remove.

$ pkgutil --only-dirs --files the-package-name.pkg | tr '
' '' | xargs -n 1 -0 sudo rm -ir

Copied from here (Wayback Machine snapshot of the original)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...