Score:0

superuser can't open gnome-terminal (Can't open display error)

kh flag

Recently I've been using ubuntu on my old laptop to host a web server (I'm using ubuntu desktop 22.10).
The problem is when I insert the command gnome-terminal -- sh /home/user/server.sh to start the servers, I get this error: Argument parsing failed: can't open display: (or something like that cause it's in another language).
However, when I start the terminal with a normal user, everything goes fine. I need to automatically start the servers with systemctl so I can't run it without superuser. What should I do? Here is a screenshot of the error in the terminal (the error is in Italian and I can't translate)

in flag
Welcome to AskUbuntu. Are you issuing this command over SSH? If so, it may not be necessary to use `gnome-terminal` as you're already where you need to be to issue commands
terdon avatar
cn flag
Why would you want to open a terminal to run a command instead of simply opening a terminal in the regular way and then running `sudo /home/user/server.sh`? Or, if with systemctl, just `/home/user/server.sh`. What is the graphical terminal (`gnome-terminal`) doing as part of this pipeline?
Xarber avatar
kh flag
I am using the command over SSH because i get the same identical error when the service starts in ubuntu and i wanted to see what was the problem. My goal is to have 2 windows of the graphical terminal open each one for an instance of peerjs, which is a nodejs package, so i need to keep the terminal open to keep it alive.
vanadium avatar
cn flag
You will need to disclose the contents of "servers.sh" because anyone can say something sensible about the issue.
Xarber avatar
kh flag
in server.sh there is just the command to start the server, nothing else. The command is `peerjs -p 8080`, which is to start peerjs library. The error has nothing to do with the file, only with the `gnome-terminal` command.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.