4

I am using Ubuntu 18.10 and I cannot launch GUI programs via the command line. This applies to subl (for Sublime Text) and Firefox. When trying to start Firefox via CLI; it prints: Invalid MIT-MAGIC-COOKIE-1 key.

My environment shows:

➜ echo $DISPLAY
:0.0

And I do have a file with that cookie:

➜ echo $XAUTHORITY 
/run/user/1000/gdm/Xauthority
➜ cat /run/user/1000/gdm/Xauthority
voltaireMIT-MAGIC-COOKIE-1OZ��8�ص������v�voltaireMIT-MAGIC-COOKIE-1OZ��8�ص������v%    

Also:

➜ xauth list
voltaire/unix:  MIT-MAGIC-COOKIE-1  4f5abfd438eb88d8b586f0fbad8aee76
#ffff#766f6c7461697265#:  MIT-MAGIC-COOKIE-1  4f5abfd438eb88d8b586f0fbad8aee76

It seems that two Xorg processes are running:

➜ ps aux | grep xorg
root      1400  0.0  0.1 213748 48068 tty1     Sl+  09:29   0:00 /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/121/gdm/Xauthority -background none -noreset -keeptty -verbose 7 -core
root      4701  1.9  0.5 658612 195732 tty2    Sl+  09:30   1:50 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 7 -core

I previously had lightdm installed to fix a login issue, and I have the current NVIDIA graphics drivers installed on my system. I guess this is very much related?

When I run:

DISPLAY=:1 subl

it works!

What could I do to fix this?


Update

I deleted ~/.Xauthority and rebooted, but the problem still remains.

2

The issue was that DISPLAY was incorrectly set to :0.0 by a shell configuration file. Once I removed that, launching programs from the shell was possible again.

You can use this command to search through all the default shell configuration files:

grep "DISPLAY" ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
               ~/.bash_aliases /etc/bash.bashrc /etc/profile \
               /etc/profile.d/* /etc/environment 2> /dev/null

There are indeed two Xorg processes, which is expected behavior, so this should not be an issue in itself.

Also, the .Xauthority file does not seem to be necessary.

  • I am having same problem, can you specify which file you removed ? Searching display doesn't give me anything. – Khurshid Alam Jan 25 at 16:26
  • @KhurshidAlam I did not remove an entire file. I just removed the DISPLAY line that was contained in one of the files. – slhck Jan 25 at 21:05
  • One of files you listed above? My profile and bashrc doesn't contain any display line though. – Khurshid Alam Jan 25 at 22:54
  • @KhurshidAlam In my case it was the .zshrc. – slhck Jan 26 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.