How to Connect To A Raspberry Pi Using X11 And Cygwin

X11 view of a Raspberry Pi using Cygwin
X11 Connection to a Raspberry Pi using Cygwin

Open up a cygwin shell and enter the following command at the prompt

$ cygstart xwin

Cygstart tells cygwin to run a command and return control to the shell, thus removing the need for two shells, one to launch the xwin application and the other to handle the ssh connection.

With the xwindow running we need to make cygwin aware of the remote display by exporting the environment variable DISPLAY with the appropriate parameters, taken from the title of the newly opened window: it will likely look something like this Cygwin/X:0.0. Enter the following command as appropriate

$ export DISPLAY=:0.0

Now start the SSH connection to the raspberry pi using cygwin with the following command and your own username and ip address

$ ssh -Y user@address

After the logon to the pi is completed start the xwindow session using the following command

$ lxsession

You should now have an x window connection to the pi along the lines of that shown above.

Linux: A Basic Guide to Processes and Threads

Processes form the base on which programs are run. They hold data relating to which files are open, what signals are pending, the processors state and address space, together with a list of what threads are executing.

Whilst the process describes the environment in which a program is executed, the specifics of that programs execution is detailed in a thread, which holds information relating to program position and stack.

A process begins with a call to fork() which creates a new process by duplicating the old one. The new process begins by executing code at the line after the call to fork(). To create a new address space and begin the execution of a new program a call to exec() is needed.

A program executes until it reaches the exit() call which terminates the process and frees its resources. A parent process can request the state of a child by calling the wait() routine, which allows it to wait for the termination of the child. If the child ends before the parent makes the wait() call then the child enters the zombie state and remains there until the parent makes the call to wait().

Threads

Threads provide a means of executing multiple code paths within a shared address space with shared open files and other resources.

Linux treats threads as processes, but sets their process descriptors up in such a way that memory, files and resources can be shared between multiple instances. The Call to create a thread for example results in a call to clone() similar to that shown below

clone(CLONE_VM | CLONE_FS | CLONE_FILES | CLONE_SIGHAND, 0)

meaning that parent and child share address space, file system information, open files and signal handlers.

A standard call to fork on the other had results in the more compact

clone(SIGCHLD, 0)

Linux Commands: tree

The tree command produces a recursive, depth indented directory/file listing, followed by a count of the number of files and directories found.

By default the tree command is not installed. Type one of the following according to the type of Linux installation you have.

$ sudo apt-get install tree
$ yum install tree

To list the contents of the directory test, descending all paths, type the following

$ tree test
tree
|-- foo1.txt
|-- foo2.txt
'-- foodir
    '-- foo3.txt

To limit the directory level descended into append the option -L to the tree command followed by the number of levels you wish to limit to.

$ tree test -L 1
tree
|-- foo1.txt
|-- foo2.txt
'-- foodir

Linux Commands: How to use wc

The wc command is used to count newlines, words, or bytes in a given file. Used with a pipe it can also be untilised for general counting operations. The following sections give a few examples of how it can be used.

To count the number of bytes in a file:

$ cat 02-Test.m3u | wc -c

To find the length of the longest line in a file. NB calling wc with the name of a file supplied results in output which contains both the answer and the file name., whilst piping to wc results only in the answer.

$ wc -L 02-Test.m3u
71 02-Test.m3u

$ cat 02-Test.m3u | wc -L
71

To count the number of files plus directories at the current location

$ ls -1 | wc -l