3

Sooo, that's the thing, for some reason now I cannot open graphical applications from the terminal, something that is curious to me is that I can launch gedit(for example) from my keyboard shortcut (i got it like Ctrl + Alt + G), but from the terminal, i got this error:

Unable to init server: Could not connect: Connection refused`
(gedit:6690): Gtk-WARNING **: 22:38:15.851: cannot open display: 1

I tried something that I got from internet: xhost + this is for (if i understood it well) for allow all the applications to start a graphical server, but it outputs:

xhost:  unable to open display "1"

I don't know why I'm getting this error because an hour ago I could launch graphic applications from the terminal. soo any help is appreciated :)

PS: this error happens with all the applications that I tried to launch from the terminal

1

3 Answers 3

0

It's usually DISPLAY=:0 instead of DISPLAY=:1 so run the following command to see if this is the problem.

DISPLAY=:0 gedit

If that works, you can make this somewhat permanent by running the following command:

export DISPLAY=:0

After exporting the correct DISPLAY variable, you can launch graphical applications from the terminal normally:

gedit
1
  • No that doesn't worked out, also the display var always has been 1 May 12, 2021 at 12:46
0

I found the problem, the problem is that i disabled my display manager (lightdm)because it doesn't allow me to log in(log in loop) and i thought that it was it's only function.

But when i reconfigured lightdm again i could launch gedit from the terminal without problems, so tecnically i did solve my problem but now i got other problem, is that when ubuntu boots how to directly show the console log in instead of the graphical log in.

But i'll try to solve it later...

Thank you anyways @mchid :)

1
  • Follow this answer and this will log you into a TTY console. Instead of using startx you can use sudo systemctl start lightdm. If you want to skip the password login for lightdm, I believe you can bypass this by changing the autologin setting in your user settings. Otherwise, you can always switch to a TTY screen by pressing CTRL+ALT+F3 (you can use F1 through F6 on lightdm) and to switch back to your graphical session press CTRL+ALT+F7
    – mchid
    May 12, 2021 at 22:05
0

Is it possible that you logged in with your personal user, but then did something like 'su' or 'sudo su' in a terminal window ? The Desktop would then be owned by you, but you are trying to run the application as root. You will get that error about the Display because root does not own the display. You were on the right track with 'xhost +', but you need to execute that before you change identities with 'su'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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