Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Uninstall XQuartz.app from OSX Yosemite/El Capitan/Sierra
launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist && \
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist && \
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz && \
sudo pkgutil --forget org.macosforge.xquartz.pkg && \
rm -rf ~/.serverauth* && rm -rf ~/.Xauthorit* && rm -rf ~/.cache && rm -rf ~/.rnd && \
rm -rf ~/Library/Caches/org.macosforge.xquartz.X11 && rm -rf ~/Library/Logs/X11
@owlboy
Copy link

owlboy commented Nov 3, 2016

Great!

@mac-n-cheese
Copy link

mac-n-cheese commented Dec 18, 2016

Help! I'm not code savvy. Does this code apply only to XQuartz.app downloaded from macosforge.org? It's not working for me as is. Terminal responds: 'No receipt for 'org.macosforge.xquartz.pkg' found at '/'. I downloaded from xquartz.org, not Macosforge. Name of package I downloaded is just xquartz.pkg. Can I substitute org.macosforge with org.xquartz?

@pwnsdx
Copy link
Author

pwnsdx commented Mar 1, 2017

@owlboy: Thanks!

@mac-n-cheese: Yes you can but I believe org.macosforge.xquartz.pkg is the only pkg name available.

@mattoo
Copy link

mattoo commented Mar 22, 2017

hello, thanks for the code !!

My Mac says "Forgot package 'org.macosforge.xquartz.pkg' on '/'." is that a big deal ?

thanks again ;)

ps: after checking, my /opt folder has reduced from 130Go to OGo... which sounds quite good ^^

@aisk
Copy link

aisk commented Mar 28, 2017

Hi i think rm ~/.cache is not a good idea, since some other software was using this path as cache folder (like bower and more, but i don't know now since it was deleted by this gist).

@pwnsdx
Copy link
Author

pwnsdx commented Apr 19, 2017

hello, thanks for the code !!
My Mac says "Forgot package 'org.macosforge.xquartz.pkg' on '/'." is that a big deal ?
thanks again ;)
ps: after checking, my /opt folder has reduced from 130Go to OGo... which sounds quite good ^^

Sure no problem.

The fact that he forgot the package actually means it has been uninstalled.

Hi i think rm ~/.cache is not a good idea, since some other software was using this path as cache folder (like bower and more, but i don't know now since it was deleted by this gist).

Maybe, I'll have to reinstall it to see which directory XQuartz use inside ~/cache which I probably won't do. Anyway it's just cache files so.

@ryenus
Copy link

ryenus commented Dec 13, 2017

@pwnsdx, probably only ~/.cache/fontconfig/ and ~/.cache/fontforge/.

@kmbuki
Copy link

kmbuki commented Jun 10, 2018

Perfecto 👍

@Burkehaven
Copy link

Burkehaven commented Sep 26, 2018

Thanks for this.

@andalike
Copy link

andalike commented Oct 19, 2018

Thanks

@jabalazs
Copy link

jabalazs commented Dec 18, 2018

Thank you!

@asha23
Copy link

asha23 commented Dec 19, 2018

Great, worked perfectly thanks... It's not nice not being able to easily uninstall something you no longer need from your computer.

@helio-silva
Copy link

helio-silva commented Jan 28, 2019

Thanks, very useful

@xasapakos
Copy link

xasapakos commented Jun 19, 2019

Hi! I have a great problem. I updated the XQuartz to 2.7.11 in my MacOs Mojave and all other related software (primarily freesurfer) stopped working. I need to remove XQuartz and then install a previous version which worked. The above-mentioned script does not apply to Mojave.. Any ideas???

Copy link

ghost commented Aug 13, 2019

I used the script on Mojave and it seams like everything is gone and everything is working fine. Thanks you very much!

@gp42
Copy link

gp42 commented Sep 20, 2019

👍

@jeffoman
Copy link

jeffoman commented Oct 14, 2019

same as FelixQuehi.
Thanks !

@barbhackk
Copy link

barbhackk commented Oct 17, 2019

Hi,
Before I used Xquartz for Inkscape. The version 1.0 Beta of Inkscape now works natively on macOS Catalina. To uninstall Xquartz it's almost the same thing.

launchctl unload /Library/LaunchAgents/org.macosforge.xquartz.startx.plist && \
sudo launchctl unload /Library/LaunchDaemons/org.macosforge.xquartz.privileged_startx.plist && \
sudo rm -rf /opt/X11* /Library/Launch*/org.macosforge.xquartz.* /Applications/Utilities/XQuartz.app /etc/*paths.d/*XQuartz  && \
sudo pkgutil --forget org.macosforge.xquartz.pkg  && \
rm -rf ~/.Xauthorit* && rm -rf ~/.cache && \
rm -rf ~/Library/Caches/org.macosforge.xquartz.X11 && rm -rf ~/Library/Logs/X11

@webmaster128
Copy link

webmaster128 commented Jan 10, 2020

The only difference between the original version and @barbhackk's version is that the later does not delete ~/.serverauth* and ~/.rnd. I did not do the research if those files strictly belong to X11, but as far as I can see, the original command does the job.

Did you remove those file from the list because you use a different shell than bash (e.g. zsh)? In zsh this fails for file patterns with no match:

rm -rf ~/.serverauth*
zsh: no matches found: /Users/simon/.serverauth*

However, this works fine in bash.

@pegues
Copy link

pegues commented Jan 31, 2020

Thanks @barbhackk, your script worked great.

@matronator
Copy link

matronator commented Apr 13, 2020

Uhmm, I kinda forgot I had Wine (thus Quartz with it) installed and already upgraded to Catalina. It's now in a "relocated items" folder and can't be deleted. Any idea how to delete it on Catalina?

@jookovjook
Copy link

jookovjook commented Aug 31, 2020

Also:

rm -rf ~/Library/Preferences/org.macosforge.xquartz.X11.plist

@sgdoerfler
Copy link

sgdoerfler commented Mar 12, 2021

XQuartz 2.8 and later requires different uninstall steps than version 2.7.X and earlier. Both are listed in the XQuartz FAQ here.

@pipiche38
Copy link

pipiche38 commented Feb 11, 2022

Still:

sudo rm -rf Previously\ Relocated\ Items
rm: Previously Relocated Items/Security/usr/X11: Operation not permitted
rm: Previously Relocated Items/Security/usr: Directory not empty
rm: Previously Relocated Items/Security: Directory not empty
rm: Previously Relocated Items: Directory not empty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment