Score:1

(gedit:3378): Gtk-WARNING **: 18:50:39.593: cannot open display:

gu flag

I can't seem to get the following code running

sudo gedit .bashrc

I always get the error (gedit:3378): Gtk-WARNING **: 18:50:39.593: cannot open display:

May I know how I can solve this issue? Thank you

Score:1
it flag

In your ~/.bashrc, set the EDITOR and VISUAL environment variables to your preferred editor.

export EDITOR=$(type -p gedit)
export VISUAL=$(type -p gedit)

After source ~/.bashrc, you can:

sudoedit .bashrc

Read man sudoedit.

sudoedit uses your sudo access to make a temporary copy of the restricted file, owned by you, then invokes $EDITOR on that temporary file. If $EDITOR returns success, sudoedit uses your sudo access to copy the temporary file back to the restricted file.

Your way fails because your display, either X Server or Wayland, is configured to reject connections from non-you UIDs. root (UID 0) is not you.

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.