01signal.com

Using a Linux desktop on a Windows computer

This web page belongs to a group of small projects that explore the features of the Smart Zynq board.

This project is also published in HelloFPGA, which is recommended for Chinese readers. There is also a short video demonstrating the method that is described on this page.

Introduction

On Linux computers, it is possible for graphical software to open a window on a different computer. In other words, the software (for example, Google Chrome) can run on one computer, but the user of this software sits in front of another computer. There are similar solutions with Windows as well, but these solutions usually offer a bad user experience. Linux is much better suited for working from a remote location.

This feature is not used often, because people usually work on their own computer or laptop. But when the computer doesn't have a monitor connected to it, this feature can be useful.

This tutorial explains how to run graphical software on Xillinux so that the mouse, keyboard and monitor are connected to a Windows computer.

The X server

The basis for the Linux desktop is X-windows. This is very old software, but it works well to this day. Unlike Windows computers, the graphical interface is based upon the X server. This is a regular computer program (running in user space) that implements a TCP/IP server. This server usually listens to port 6000. Any program that wants to display a window on the computer's screen connects to this server through TCP/IP. All graphical information is sent through this TCP/IP connection. The user's keyboard strokes and mouse movement is also transmitted through this connection.

The program that controls the window can run on the same computer or from a different computer. This doesn't matter, because the connection is based upon TCP/IP.

On most Linux computers today, it's not possible to connect to the X server directly through TCP/IP from a different computer. This feature is turned off because of security concerns. Besides, there is a safe alternative for making such connection between two Linux computers: "ssh -X". Nevertheless, the graphical programs that run on a Linux computer are usually capable to connect to another computer's display.

It is therefore useful to run an X server on a Windows computer. This X server allows programs that run on a different computer to present their GUI interface on the Windows computer. I shall present two options: At first, a full Linux desktop will appear on the Windows computer. The next step is to present only one window that belongs to a computer program that runs on the Linux computer.

Preparations

First of all, download and install vcxsrv. The installation procedure is the same as with any Windows application.

The next step is to find the IP address of the computer that runs Windows: Use ipconfig inside a Command Prompt as follows:

> ipconfig

Windows IP Configuration


Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . :
   IPv4 Address. . . . . . . . . . . : 192.168.1.11
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 192.168.1.3

The next step is to turn off Windows Defender Firewall. Otherwise, computer programs that run on Xillinux will not be able to connect to the X server. In fact, even ping from Xillinux will fail.

Obviously, turning off the firewall makes the computer vulnerable to attacks from the network. It's therefore recommended to consider if the computer network is protected by an external firewall before carrying this out.

Go to "Turn Windows Defender Firewall on and off".

Turning off Windows Defender Firewall, stage 1

Then turn off the firewall:

Turning off Windows Defender Firewall, stage 2

After the firewall has been turned off, verify that the Xillinux board can connect with the Windows computer. For example, try ping on Xillinux:

root@localhost:~# ping 192.168.1.11
PING 192.168.1.11 (192.168.1.11) 56(84) bytes of data.
64 bytes from 192.168.1.11: icmp_seq=1 ttl=128 time=0.797 ms
64 bytes from 192.168.1.11: icmp_seq=2 ttl=128 time=0.790 ms
64 bytes from 192.168.1.11: icmp_seq=3 ttl=128 time=0.782 ms
^C
--- 192.168.1.11 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.782/0.789/0.797/0.033 ms

Run a Linux desktop on Windows

In order to start vcxsrv, click on the icon named XLaunch.

On the first pop-up window:

vcxsrv's first popup window

On the second pop-up window: Select "Start no client".

vcxsrv's second popup window

On the third pop-up window: Select "disable access control". This makes it possible to connect from the Xillinux board.

vcxsrv's third popup window

After these three pop-up windows, vcxsrv opens a large and empty window. Everything in this window is black.

Now we shall fill this large window with Xillinux' desktop. Type this on a shell on the Xillinux board:

root@localhost:~# DISPLAY=192.168.1.11:0 /etc/X11/Xsession

The graphical desktop appears on the Windows computer a few seconds after this command.

It is also possible to use ssh to start the desktop. For example, suppose that the Xillinux board's IP address is 192.168.1.123. This command can be used in a Command Prompt window (on the Windows computer).

> ssh root@192.168.1.123 "DISPLAY=192.168.1.11:0 /etc/X11/Xsession"

It is required to set the password of the root user before using ssh.

Note that it's possible to use Copy inside vcxsrv's window and then use Paste on a regular Windows window. It also works the other way around.

"/etc/X11/Xsession" is the command that starts the desktop. "DISPLAY=192.168.1.11:0" assigns a value to an environment variable. This tells the program to connect to a remote computer.

The DISPLAY assignment consists of two parts. The first part is the IP address (192.168.1.11 in this example). The second part is the Display Number. Recall that when you started vcxsrv, the Display Number was chosen to be 0. This is why the second part of DISPLAY is ":0". This tells the TCP client to connect to port 6000. If we choose a different Display Number, we need to change DISPLAY accordingly. For example, if the Display Number is 5, DISPLAY should be "192.168.1.11:5" instead. The TCP client will attempt to connect to port 6005 in this situation.

Open a single Linux window on Windows

I shall now show how to run a graphical computer program on Xillinux, so that the window opens on the Windows computer.

Start vcxsrv like before, but with one difference: Instead of choosing One Large Window, choose Multiple Windows. Except for this difference, make the same choices as before.

vcxsrv's first popup window, multiple windows

Unlike before, no new window will open after the three pop-up windows. It will appear as if nothing happens after the configuration is finished. But this is misleading. The X server is running and it is waiting for requests.

For example, try this on Xillinux:

root@localhost:~# DISPLAY=192.168.1.11:0 gnome-text-editor &

This starts a text editor on the Windows computer. It's also possible to start a terminal window:

root@localhost:~# DISPLAY=192.168.1.11:0 lxterminal &

Opening a terminal windows in this way has an advantage: There is no need to add the "DISPLAY=192.168.1.11:0" part anymore: This is the default for all commands that are started on this terminal.

As mentioned before, it's possible to send the command through ssh: Type this on Windows' Command Prompt in order to start a terminal window:

> ssh root@192.168.1.123 "DISPLAY=192.168.1.11:0 lxterminal"

As before, this example assumes that the Xillinux board's IP address is 192.168.1.123.

Unfortunately, there doesn't seem to be a simple way to shut down the X server. When the X server runs in this mode, there is no window that represents the program. The method to stop the server is therefore to use the Task Manager: Find the task named "VcXsrv windows xserver", and click "End Task".

Copyright © 2021-2024. All rights reserved. (6f913017)