Gparted not working on TW today.

I am trying to run gparted but am not succeeding and get the following error warning:-

alastair@localhost:~> sudo gparted 
[sudo] password for root:  
Unable to init server: Could not connect: Connection refused 

(gpartedbin:10388): Gtk-**WARNING** **: 18:27:11.297: cannot open display:  
alastair@localhost:~> 


Any ideas how I can get it working again please?
Budge.

Hi
What hardware/gpu? All good here on x86_64 with amdgpu and on nvidia offload, with Xorg. I never use sudo, always su -. What if you launch from the desktop entry?

Where do you run this from? From a terminal emulator inside a desktop? AFAIK (never used it) it is a GUI program.

That’s guaranteed to not work, because “sudo” does not pass $DISPLAY to the command.

Open a root konsole, and run “gparted” from the command line. Or use “kdesu” in place of “sudo”.

How do you know it is X11 and not Wayland? I do not see anything in original post and I would say today this is the first question to ask.

For X11 DISPLAY is not enough - you also need to pass XAUTH (or allow access to server by some other means). This is done by pam_xauth module which also sets DISPLAY variable. It is used by default for su, but not for sudo.

For Wayland - I do not know if any similar mechanism exists.

Hi and many thanks to all. Ignorance is bliss and I have no idea if this laptop is running with Wayland, X11 or what.

I used sudo because that is what I have used previously without issues, but some time ago. I tend to use sudo out of habit from working on RPi etc. but also use su -.

As suggested above I used su - and then gparted ran correctly and opened in the gui. I shall stick with su - in future.

Problem solved, for which many thanks. Also USB issues now resolved so thanks to all.

Budge.