sudo -H gedit /etc/fstab (base) (gedit:22533): Gtk-WARNING **: 11:39:03.464: cannot open…
- User
sudo -H gedit /etc/fstab (base)
(gedit:22533): Gtk-WARNING **: 11:39:03.464: cannot open display:
- Assistant
This error message indicates that the
geditprogram is unable to open the display, which is typically the result of trying to run a graphical application in an environment where it doesn't have access to a graphical user interface (GUI).Here are some potential solutions to this problem:
-
Check if you're on a GUI-enabled environment: Ensure that you are running this command within a graphical user session. If you're operating from a text-only virtual console (e.g., using
Ctrl + Alt + F1-F6), switch to a GUI session (typicallyCtrl + Alt + F7). -
Setting the DISPLAY variable: Make sure the
DISPLAYenvironment variable is set. You can verify this by runningecho $DISPLAY. If it's not set, you can set it by using:export DISPLAY=:0This assumes your display is
:0, which is commonly the case, but may differ. -
Using
xhostto allow access: You might need to permit users to connect to the X server. Run the following command:xhost +local:Note that this is a broad permission that may reduce security.
-
Using
sudowith GUI applications: Instead of usingsudo, try usingsudo -Eor installgksudo,gksu, orgksu-polkit(depending on availability in your distribution) to preserve environment variables related to the display. For example:sudo -E gedit /etc/fstabor
gksudo gedit /etc/fstab -
Running the application in a proper environment: If
geditstill fails to launch, consider using a terminal-based editor such asnanoorvito edit/etc/fstab:sudo nano /etc/fstab -
Troubleshooting permissions and access rights: If none of the above works, you might want to check if the system has any restrictions on which users can access the X server. Look for settings or configurations in
/etc/X11/Xwrapper.configor similar files.
Apply these methods according to your specific operating environment and access needs. Remember to be cautious when editing system files like
/etc/fstab, as incorrect edits can affect system boot and operation. -