Cleaning Up Residual Files on macOS After Deleting Apps

After deleting apps on macOS, they tend leave behind residual files and directories throughout the system. You can use the find command to find these files after an app has been deleted. I’ll be deleting the LastPass app and removing its residual files as an example because nobody should be using LastPass anyway.

Searching for Residual Files and Directories

To find directories and files related to LastPass, I ran a system-wide search using find. I exlcluded directories such as /System/Volumes/Data since those result in errors like “Operation not permitted”. I also excluded Homebrew directories that don’t need to be cleaned up. You can add more directories as needed, just make sure to not add a trailing slash to the filepaths!

find / \
-not \( -path /System/Volumes/Data -prune \) \
-not \( -path /usr/local/Homebrew -prune \) \
-not \( -path /usr/local/Cellar -prune \) \
-not \( -path /usr/local/Caskroom -prune \) \
-name \*lastpass\* 2>&1 | grep -v -E 'Operation not permitted|Permission denied|Not a directory'

The command may take some time to complete depending on your machine specs and amount of files you have. It took around ~10 minutes for me on an 2019 Macbook Pro with an i7 Intel CPU.

Here’s the output I got from the command above. I can now go through each of these files and folders and decide if I want to delete them manually:

/Users/nelson/Library/Application Support/com.lastpass.lastpassmacdesktop
/Users/nelson/Library/Application Scripts/
/Users/nelson/Library/Application Scripts/com.lastpass.lastpassmacdesktop.safariext
/Users/nelson/Library/Group Containers/
/Users/nelson/Library/Group Containers/
/Users/nelson/Library/Group Containers/ Scripts/
/Users/nelson/Library/Containers/com.lastpass.lastpassmacdesktop.safariext/Data/Library/Application Scripts/com.lastpass.lastpassmacdesktop.safariext

This could probably be automated all the way through the deletion step, but I prefer to double check what is actually going to be deleted.

Also, this may help to free up space on macOS, but I mainly did it because I like keeping my system tidy.

Try this out with whatever apps you’ve deleted in the past. You can also try finding files and folders be specifying a company name. For example, replace \*lastpass\* with \*microsoft\* and see what you get!