Sample Header Ad - 728x90

How do I correctly (re)set $DISPLAY?

1 vote
4 answers
14188 views
I connect from a Windows PC to a Linux PC with ssh using MobaXTerm. Within the ssh session, I have a tmux session with a few windows and panes. The ssh session will typically disconnect after a few hours of inactivity (I've tried toying with what looked like relevant keep-alive settings in MobaXTerm, but it's never worked). First-world problem: After starting a new ssh session and _reattaching to my existing tmux sessions_, the $DISPLAY variable will sometimes be set "incorrectly" - by which I mean, when I launch a GUI that uses X-Windows (e.g. Firefox), I'll get "cannot open display" error messages. E.g.:
$ firefox &
 23077
$ Unable to init server: Broadway display type not supported: localhost:11.0
Error: cannot open display: localhost:11.0

+  Exit 1                  firefox
$ echo $DISPLAY
localhost:11.0
Usually when I open a _new_ terminal, I'll get the updated/correct value of $DISPLAY - from this terminal, I'll be able to successfully launch X-Window-using GUIs. **Question: is there any way I can dynamically "update" the value of $DISPLAY in an _existing_ terminal (i.e. a terminal that's been alive since before the ssh disconnection)?** I.e. I'd like to try avoid having to launch a new terminal just for the purpose of getting/discovering the new value of $DISPLAY. I don't really have a solid understanding of what $DISPLAY represents - so I'd be grateful if someone could explain what it represents and does in the context of the described.
Asked by StoneThrow (1937 rep)
Jun 6, 2020, 05:28 PM
Last activity: Mar 24, 2025, 05:16 PM