Linux gtk warning cannot open display

When starting gparted «Gtk-WARNING **: cannot open display:»

This is exactly my problem. running ubuntu server 12.04. sorry I couldn’t find a way to mark the thread «unanswered». Resize a 2TB partition on a 3TB disk created with fdisk I downloaded and installed gparted — however I get an errors when trying to run it. can you guys help me? my terminal output is below:

keysersoze@the-usual-suspects:/$ sudo gparted /dev/sda (gpartedbin:18064): Gtk-WARNING **: cannot open display: keysersoze@the-usual-suspects:/$ 

gparted is a gui, so you should be launching it from command line with gksudo or gksu. But if you have 2TB that is MBR(msdos) you may need to convert to gpt(GUID). You can use gdisk for conversion as well as setting up partitions.

7 Answers 7

The trick here is to use an Xserver on another machine to display the GUI elements you can’t see on a server. Set the environment variable to the local machine running the Xserver. Where this is an IP address and the screen # on the X server.

With another Ubuntu machine you will need to change firewall rules to allow this. Using windows you can do this with MobaXterm which runs a local X server.

Continue on your own risk

(Please, go to the next section if you want a more secure method to resize ext partitions)

The tool you are looking for is parted which is the backend for gparted, also you must make sure that your partition table is GPT, if it’s MBR it won’t support partitions bigger than 2TB.

This method is only for non-mounted partitions, so you might like to do a backup too if something go wire.

braiam@bt:~$ sudo parted [sudo] password for braiam: GNU Parted 2.3 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) 
(parted) select New device? [/dev/sda]? /dev/sd sda sda1 sda2 sda3 sda4 sda5 sda6 sda7 sda8 sdb sdc sdd sde sdf sdf1 sdf2 New device? [/dev/sda]? /dev/sdf Using /dev/sdf (parted) 
(parted) print /dev/sdf Model: SanDisk Cruzer (scsi) Disk /dev/sdf: 8040MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 32.8kB 2418MB 2418MB primary boot, hidden 2 2418MB 8039MB 5621MB primary ntfs 

Hence, number should be 1 , start should be the same 32.8kB and the end should be 8039MB (remember that you should change the numbers, since I don’t have a >1TB drive).

resize 1 32.8kB 8039MB WARNING: you are attempting to use parted to operate on (resize) a file system. parted's file system manipulation code is not as robust as what you'll find in dedicated, file-system-specific packages like e2fsprogs. We recommend you use parted only to manipulate partition tables, whenever possible. Support for performing most operations on most types of file systems will be removed in an upcoming release. 

Nice warning, continue reading.

Читайте также:  Менеджер обновлений для linux

Seems that the message is quite old, and e2fsprogs is not called like that anymore (the package keep its name, through), but resize2fs . This program is capable of resize any ext2/3/4 filesystem. Cool! Now how I do it? Simple:

sudo resize2fs /dev/sdf1 8039M 

(Remember that the size is the current size + the size you want to add)

Here you could use M for Megabytes, G for Gigabytes. You should also verify for errors:

Источник

How to Fix (main:30677): Gtk-WARNING **: cannot open display: ?

If you are facing this error (main:30677): Gtk-WARNING **: 05:40:47.665: cannot open display: just install Gtk+ development library, and set the display screen to 0.

Installing Gtk+ using Homebrew

If you are using a UNIX-like OS such as Mac OS X, or a Linux distribution. You can use Homebrew package manager to install Gtk+ as following.

Install Gtk+ using apt

If you are using Debian, Ubuntu, Elementary OS, Linux Mint, .. You can use this command to install Gtk+.

sudo apt-get install libgtk-3-dev 

Set DISPLAY Environment Variable

If the error persists, just run this command on terminal to set the display to the current display/monitor/screen.

If the display command fixed the error, add those lines into your .bashrc or .zshrc (according to what you are using).

if [[ -z "$DISPLAY" ]] then  DISPLAY=":0"  export DISPLAY fi 

Use X11 XQuartz on Mac

If your application still showing the same error on Mac OS, just install XQuartz from here https://www.xquartz.org and restart. Your Gtk apps will work after that.

I hope this helps. Do you recommend reading this blog post? share it!

Источник

xhost: unable to open display «0»

I have installed /usr/local/stata/xstata-mp as root, permissions 755. When I try to run this program from a non-root account via the terminal, I get:

user@host ~ % /usr/local/stata/xstata-mp (xstata-mp:8030): Gtk-WARNING **: 10:09:24.384: cannot open display: 0 

«That’s odd,» I think, I just know I set DISPLAY=0 in my .zshrc, «Well, maybe I need to explicitly do so when running this command?» So I try:

user@host ~ % DISPLAY=0 /usr/local/stata/stata-mp (xstata-mp:8201): Gtk-WARNING **: 10:13:28.638: cannot open display: 0 

Edit: per @steeldriver ‘s comment I have also tried DISPLAY=:0 I have a gander around, and find Why don’t gksu/gksudo or launching a graphical application with sudo work with Wayland? which seems promising (although I am not using Wayland, I am on Ubuntu 18.10 and Wayland remains installed). I try the below command as user@host, and as su in an administrative account:

user@host ~ % xhost -si:localuser:root xhost: unable to open display "0" 
user@host ~ % DISPLAY=0 xhost -si:localuser:root xhost: unable to open display "0" 

I try other display numbers all to no avail. I think «I am a newb, maybe localhost really means [LOCAL USER] and try with the permutations mentioned above.

user@host ~ % xhost -si:user:root xhost: unable to open display "0" 

It turns out I am a newb, but that didn’t help. 🙂 How can I make the xhost magic happen so that Gtk doesn’t throw a fit and I can just launch my application (as user@host)? EDIT 3-22-2019:

pgrep -a Xorg 3907 /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/123/gdm/Xauthority -background none -noreset -keeptty -verbose 3 7370 /usr/lib/xorg/Xorg vt2 -displayfd 3 -auth /run/user/1000/gdm/Xauthority -background none -noreset -keeptty -verbose 3 

Источник

How do I fix a «cannot open display» error when opening an X program after ssh’ing with X11 forwarding enabled?

After launching the X11 app (XQuartz 2.3.6, xorg-server 1.4.2-apple56) on my Mac (OS X 10.6.8), opening an terminal in X11 and running xhost + , I then ssh -Y to my Ubuntu 10.04 VM (running on VMware Fusion). When I run gedit .bashrc (for example), I get:

(gedit:9510): Gtk-WARNING **: cannot open display: 

set | grep DISPLAY returns nothing. But if I ssh -Y into my Ubuntu 11.04 machine, gedit .bashrc works. echo $DISPLAY returns «localhost:10.0». I tried export DISPLAY=localhost:10.0 while sshed into my VM and then running gedit .bashrc , but I get:

(gedit:9625): Gtk-WARNING **: cannot open display: localhost:10.0 

What could be different in the configuration of the two difference Ubuntu machines that would explain why one works and the other doesn’t? Update: As suggested by Zoredache in the comment below, I ran sudo apt-get install xbase-clients , but I continue to have the same problem.

Читайте также:  Отличие терминала от консоли линукс

Does the Ubuntu 10.04 box have the proper tools for X11 installed? Install xbase-clients, if it isn’t installed already.

Maybe try passing the -vv option to ssh when you connect, this prints verbose debug messages, you should see several comments about X11 forwarding while connecting.

@jcrawfordor You did check the X11Forwarding on the ubuntu one, and that you have xbase-clients installed and that you can start Xapps on the mac on the terminal you’re making ssh connection from. (Check that $DISPLAY is set on the terminal you run ssh from.

16 Answers 16

Check the server’s sshd_config (normally /etc/ssh/sshd_config ), and make sure X11Forwarding option is enabled with the line

If X11Forwarding is not specified, the default is no on the Debian machines I have available to check.

I discovered after setting up another Ubuntu VM, that I need to both install xbase-clients and enable X11Forwarding. Update your answer to include both and I’ll accept it.

Interesting. At least on the new install of 10.04 that I did this morning X11Forwarding was enabled by default. The Ubuntu guys must be messing around with defaults again.

@DerfK, in my system «X11Forwarding yes» was there already still I am getting error as, (gedit:8381): Gtk-WARNING **: cannot open display: in such cases

This should not be the accepted answer — the question clearly specified that X11 forwarding was already enabled. Total waste of time .

Answer: You can fix the “cannot open display” error by following the xhost procedure mentioned in this article.

Allow clients to connect from any host using xhost+

Execute the following command to disable the access control, by which you can allow clients to connect from any host.

access control disabled, clients can connect from any host

Enable X11 forwarding

While doing ssh use the option -X to enable X11 forwarding.

Enable trusted X11 forwarding, by using the -Y option,

Open GUI applications in that host

After opening ssh connection to the remote host as explained above, you can open any GUI application which will open it without any issue.

If you still get the “cannot open display” error, set the DISPLAY variable as shown below.

Note: IP is the local workstation’s IP where you want the GUI application to be displayed.

Читайте также:  Linux opened files by user

For those having similar issues on OS X, also make sure you have XQuartz installed, otherwise none of these fixes help. (OP’s question shows he has XQuartz, so this is more a side note to those having similar issues as I was)

Note that running xhost + is very unsecure and should not be used! As Stefan Rogin mentioned, the attacker can then from the host connect to your XSession, read all you type, or even alter the screen you see.

I’ve had this problem when logging into a Ubuntu VM from Mac OS X as well — it doesn’t seem to like ‘localhost’ in the display variable for some reason. So set the IP manually, as harrymc suggests:

Then X11 programs should be fine. It doesn’t seem like it should be necessary to tell the OS that localhost and 127.0.0.1 are equivalent, but it works, at least.

BINGO! I’ve been stuck by that problem for some time. I connected by SSH and couldn’t launch Gtk programs (plain X11, like «xeyes», worked however). DISPLAY was correct. Actually, the resolution of «localhost» wasn’t! If I set manually DISPLAY=127.0.0.1:10.0, or DISPLAY=::1:10.0 it does work. Editing /etc/hosts seems to have no effect; and DNS is correctly configured («dig localhost» correclty report both 127.0.0.1 and ::1) So, it seems to be a bug in whatever does DNS resolution for X11 connections in Gtk (gtk? gdk? glib? other?).

On a Debian install for the Beagle Bone Black, /etc/host was not set to readable by anyone but root. This caused the symptoms reported here. Made /etc/hosts readable by all, and it worked fine.

more than likely this answer works because 127.0.0.1 localhost is not defined within the /etc/hosts file as most debian based distros setup 127.0.1.1 localhost thus when you manually set this env var after logging in, things begin to work. I added the above entry to /etc/hosts and i no longer have to manually set the DISPLAY env var after logging in.

I had this problem with my CentOS KVM server, I was missing the «xauth» program.

If you have this problem after some time when running with -X arg. or just ForwardX11 in /etc/ssh/ssh_config, then run $ ssh username@hostname -Y , to enable trusted X11 forwarding, don’t know the exact cause but I’m guessing with -X some features expire after some time, probably to increase security.

Here is what I found online :

If you use ssh -X remotemachine the remote machine is treated as an untrusted client. So your local client sends a command to the remote machine and receives the graphical output. If your command violates some security settings you’ll receive an error instead.

But if you use ssh -Y remotemachine the remote machine is treated as trusted client. This last option can open security problems. Because other graphical (X11) client could sniff data from the remote machine (make screenshots, do keylogging and other nasty stuff) and it is even possible to alter those data.

If you want to know more about those things I suggest reading the Xsecurity manpage or the X Security extension spec. Furthermore you can check the options ForwardX11 and ForwardX11Trusted in your /etc/ssh/ssh_config.

Источник

Оцените статью
Adblock
detector