1

I am using SSH to login into my Linux RedHat server from my Windows machine. I want to create a GUI in python on the server but I am not sure if there exists any Desktop environment on the server. I gave the command echo $DESKTOP_SESSION but it did not give any result. I am not sure if I was required to give that command but I just checked.

I would like to know, how do I check if there exists any desktop environment on the server or not? I would also like to know if I can run a python file for GUI using command line or I will have to remotely access server's desktop environment using Virtual Network Computing (VNC) or something.

I am really new to most of these things so I might have made some mistake. Please comment if any other detail is required.

  • You have a typo in $DESKTOP_SESSION. Anyway this variable is populated in the desktop session itself when desktop is starting, you can't expect that shell you get when you login via ssh will have this variable defined. – marbu Apr 22 '15 at 8:09
  • Do you want to know of a desktop session is running or whether you have any installed? – terdon Apr 22 '15 at 10:03
  • @terdon I would like to know both. – Vipul Apr 22 '15 at 10:41
  • What do you mean by “a GUI in python”? You can run a GUI program on a machine that doesn't have a display. The Unix display is automatically forwarded over SSH connections (if enabled). You don't run a desktop environment on the server, it runs on your local machine and can show programs running on other machines. – Gilles 'SO- stop being evil' Apr 22 '15 at 22:23
  • @Gilles By GUI, I meant a script which will come up with some display on execution. Since the server does not need to have a display as you mentioned, my doubt is clear. I just would like to know one thing, is there anything in particular which we need to do to run the script apart from what we do during normal scripts execution. – Vipul Apr 23 '15 at 5:02
2

In the Unix world, you can run a GUI program on one machine and have it displayed on another machine. This is because the X window system, which provides basic GUI facilities, was designed to be network-transparent. The easiest way to do that between Unix machines is to use SSH: the command ssh myserver myapp runs myapp on myserver, and if myapp has a graphical display, it will show up on the local machine. (The feature may need to be enabled in the client or server configuration; it's authorized in the default server configuration on Red Hat.)

From a Windows machine, you can get the same thing by installing an X server. I use Xming. Install it on your Windows machine, and also install an SSH client such as PuTTY. By default, Xming has its own window on the Windows machine, and all X applications display inside that window; to display each X application in its own window, change the Xming startup to add the -multiwindow option, i.e. run Xming -multiwindow. In PuTTY, enable X11 forwarding. Use PuTTY to log in to the Linux server, and run your GUI program.

You will of course need to install all the libraries that the program uses on the server, including libraries for GUI functionality (X11, Gtk, etc. depending on what the program uses). You do not need to install an X server or a desktop environment on the server, since this functionality is provided by your (Windows) client.

0

Better change your approach. Install on your desktop some X servers. This will help you run X applications on the server and have interface on your machine. For example MobaXterm provide you in one package ssh and X server.

Install/run desktop environment on the server is nonsense

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.