Administering Linux Remotely

1.0 Introduction

Is there an alternative way of administering a Linux/Unix box remotely that avoids these problems of excessive bandwidth and poor graphics display?
YES!! and it's called  'Remote X'.

2.0 Before we start...

One bit of terminological confusion stumped me for a while. I talk about the Linux 'server', and the Windows PC being a client of that server -and that, of course, is the usual way we think about these sorts of things. But when you're dealing with X, it's the wrong way around. The X client is the program running on the Linux server that wants to paint graphical bits of goodness onto a screen somewhere. So the X client runs on what you (and I!) think of as the server.
Similarly, an X server is simply a program that runs on the client PC nearest to you, where you want the graphical goodies to appear. So the X server runs on what we'd ordinarily call the client PC.
So an X server runs on the client (PC), and X clients run on the Server. Got that? Good!

3.0 The Linux Machine Specifications

I installed the Centos clone of RHES4, because it's free and you can download updates for it. I could equally well have chosen White Box, because they do a nice RHES4 clone, too... but I'd stored that particular download on a DVD, and my Linux server only has a CD-ROM, so the Centos CDs won the day.
The installation was perfectly standard stuff: if you have read how I install Linux onto my virtual machines, then you'll know exactly how I did it. In essence, make it a Custom installation that includes the Development Tools packages. Make sure you configure networking correctly (the machine will need to see the XP Desktop PC, after all). And I suggest no firewall to start with, just so you can get things running quickly. Once you've got it all working, you might well want to switch on the firewall in a carefully controlled manner, making sure it doesn't screw up XP PC -> Linux Server X communications in the process.

4.0 Configuring X on the Linux Machine

Anyway, the point is, that if you're using Gnome too, you will need to edit the /etc/X11/gdm/gdm.conf file in a text editor. Find the section labelled [xdmcp] and change the line Enable=false to Enable=true. If you'd rather achieve the same thing without editing a text file, you can click the Applications -> System Settings -> Login Screen menu options, and then select the XDMCP tab:

Enabling of Remote X administration with a GUI tool

Selecting the Enable XDMCP option at the top of the screen and leaving everything else at its default settings achieves exactly the same thing as editing the text file in the manner I described earlier. 

If you're using KDE, then you will need to edit /usr/share/config/kdm/kdmrc, and again find the section labelled [Xdmcp] and change Enable=false to Enable=true. I am sure there is a graphical tool for KDE users to achieve the same thing, just as there is for Gnome... but since I don't use KDE, I don't know what it is. Sorry!

With one or other of those files edited and saved, now use your favourite text editor to edit /etc/X11/xdm/Xaccess. Find the line which reads

#*                  # any host can get a login window

...and get rid of that # (hash) character at the beginning of the line (uncomment it, in other words). I should mention that this now blows security right out the window, since in a production environment it would mean that any humble user, if they knew what an X Server was and how to install one, could now call up onto their PC the screen needed to log on to the Linux machine. Perhaps more appropriate in a production setting would be to list here the hostnames of those PCs used by system administrators, for whom it would be entirely appropriate to permit remote administrative capabilities. Unlisted hosts could not then act as usable X Servers.

With the remote X capabilities enabled one way or another, all you do now is restart X on the Linux machine. You could do that by rebooting the box or achieve the same result far more efficiently by simply pressing [Ctrl]+[Alt]+[Backspace].

5.0 Obtaining an X Server

The X Server, remember, is what's going to be running on your PC and displaying the Linux machine's desktop for us. As such, it's a piece of software that needs to be obtained and installed. This isn't hard! If you type the phrase Windows X Server into Google, you'll get something like 31 million different hits! There are commercial X Servers such as Exceed (from Hummingbird, which the Oracle documentation always used to make reference to) or Reflections. But these are pricey (Exceed's basic offering costs US$545).

Fortunately, there are also a number freebie X servers available for home use, and perhaps the easiest (certainly, I'd say, the most well-known) is Cygwin. Cygwin is actually a Windows implementation of the Linux APIs, so it's much more than just an X server... but the important point is that it includes a free X server as part of its general (incredibly clever) goodness. (If you are familiar with WINE on Linux, then think of Cygwin as an anti-Wine. Instead of letting Linux run Windows programs, Cygwin lets Windows run Linux programs).

So, to begin with, create two directories on your desktop PC. I call mine C:\cygpkg and C:\cygwin, but the names can be anything you fancy... just don't put any spaces in the second one's name. The first of these directories is going to be where all the Cygwin packages and libraries are going to be downloaded to. You can zip this up at any time, and you'll have yourself a local copy of packages for future installations. The C:\cygwin directory is where Cygwin will actually be run, and will become the root directory within the Cygwin shell.

With that done, go to and click on the Install or update now! link you see in the rigth top corner. That will allow you to download the 280K Cygwin setup.exe program. Save it in the c:\cygpkg directory you created earlier. All you've downloaded so far is a 'bootstrap program' which will, when double-clicked, ask you for details on what other components to download, and from where it should download them. Double-click the setup program, therefore, and you'll first see a welcome screen. Click [Next], and you'll see this:
Choosing a download source

To begin with, you'll have to take the same option you see me taking here: download and install from the Internet. The other two options allow you simply to download packages but not install them, or install them from a previously-downloaded set of packages.

Specifying a root directory

On this screen, you specify what Windows directory will be used as Cygwin's root directory (that is, when you run Cygwin, where on the physical file system will the command cd / take you). This is where you specify the second of the two directories you created earlier. The screen defaults to a suggestion of c:\cygwin, but you can change it if you used a different name earlier. The other entries can be left at their defaults.
You're about to download a lot of software packages (potentially hundreds of megabytes of them if you're not careful). They need to be stored somewhere, so this is where you type in the name of the package directory you created earlier.

How to connect to the download source

Cygwin needs to be told how to access the Internet. I used the 'use Internet Explorer settings', but you should choose whatever option is appropriate.After a bit of downloading, you'll see this list of servers from where Cygwin can download its packages. Pick one that is geographically close to you because that way things might go a little faster for you (I choose
Once a download site has been selected, a dialog appears showing its progress. It indicates that a small (about 90K) file is being downloaded. The contents of that file will tell the setup program which packages are available from the particular download site you selected. You'll eventually see this sort of display:

Choosing the X packages

At the far left, a series of categories will be listed. Packages are available for editing files, web hosting and related activities, games, publishing shells... you name it! By default, very few of these packages are selected for installation, so you might want to spend some time clicking on the category name in that categories column, because that will expand the category, as in the screenshot, to reveal the individual packages available for download within that category. If you keep clicking the word in the 'Category' column that appears after the 'loopy arrows' symbol, you'll see that it cycles through four possible settings: Default-> Install -> Reinstall -> Uninstall. If you click it so that is says 'install', then all packages within a category are selected for download (which usually means a big download). But you could then expand the category and uncheck individual packages.
It is all a bit tricky to describe, but a lot easier to actually do!
Anyway, the point from this article's perspective is that you can leave everything at its default setting, so long as you do as the screenshot suggests and add in the X11 packages to the mix: a purely default installation is not sufficient to give you a viable X Server. Whilst you're at it, if you are looking to use Cygwin more widely than just as a cheap X server (and it's worth exploring at some length, I think), you may well want to download some further packages in addition to the X11 ones: vim, for example, or pine (and hence pico) to give you a text editing capability would be high on my list of desirable downloads. Be warned that asking to download everything in every category will involve downloading about 800MB of software! A totally default set of downloads will max out at around 13MB. What's needed to run an X Server comes somewhere between those two extremes, of course. So as a minimum select:

You'll now see a sort of progress indicator as all your packages are downloaded. Once the download has finished, an installation phase is automatically invoked, and the software packages are copied from the c:\cygpkg directory to their correct place in the c:\cygwin directory, and at that point, you're ready to run Cygwin properly for the first time. Incidentally, I stress that the packages are copied: withint the c:\cygpkg directory itself, you'll find an oddly-named directory (something like http%3a%2f%2fname.of.server%2finstall\release) within which the software downloads reside, even after installation. In the future, therefore, you can re-install from this store of downloaded packages by re-running the setup program and changing your answer for the screen shown in the first screenshot on this page (to "Install from Local Directory").

6.0 Running the X Server

As the installation phase ends, it asks whether it should add an icon to your desktop and/or your start menu. Let it do one of those at least, and then either double-click the desktop icon, or click the Start -> Programs -> Cygwin -> Cygwin bash shell menu items. That launches the Cygwin shell as you see it here (it's actually running in just a standard DOS box, so you can click the Cygwin icon in the top left-hand corner of the screen and select the Properties item to be able to configure different colours, fonts and window size, if you like):

Running Cygwin for the first time

The first time you run Cygwin, three lines of Linux-y mysteriousness that you see in the screenshot will be displayed. That's just setting up some links to make the whole thing work properly. After that, you're ready to start an X server, which the Linux machine will be able to use as its display. That's easily done, and requires only that you type the command (this is ONLY if you connect to one BOX ONLY):

x -broadcast the Cygwin/bash command prompt. Immediately you do so, you'll see your Linux machine's log on screen appear in a window which will be sized to occupy your PC's entire screen. If you just get a screen-sized grey box, then it's usually because network connectivity between your PC and the Linux server has not been configured correctly. If your PC is running XP, another cause of blank, grey X Windows is the in-built firewall. It should have asked you to allow XWin to be unblocked, but if you'd answered incorrectly at that point, you're going to be in trouble. If that happens to you, then manually run the Windows Firewall utility (it's in the Control Panel), and click the Exceptions tab, the Add Program button, browse to the c:\cygwin\usr\X11R6\bin directory, and select the XWin program manually. If you're using another sort of firewall, it too needs to be permitted to allow this sort of network traffic through. You may also find that program already appears as an item on the list of possible exceptions automatically identified, and if that's the case, you just need to select that item to unblock the program.

If you get it right, though, then you can log on to your Linux machine from the comfort of your Windows PC... and note that everything now displays at the native resolution of your Windows PC, not whatever graphic mode you configured the Linux server to use when you first installed it. It's also pretty light on network traffic (at least compared to something like VNC).

7.0 Installing Oracle 10g Remotely

Anyway, if you get this far, you'll now be wanting to install Oracle onto that Linux machine. Now, I was expecting to have to set DISPLAY environment variables left, right and centre as part of such an install... but I didn't. The way I installed Oracle 10g and created a database was precisely the same way as I documented in this article. In fact, I cut the snippets of command prompt stuff that need to be used on the Linux server directly out of that article, and pasted them straight into a terminal window without alteration, so I know those intstructions work perfectly fine, even though in this case the installation was onto RHES4 (the other article uses RHES3) and it was being done remotely (the other article does it locally). The X Server's existence made not the slightest bit of difference to the original installation instructions, anyway.So there you have it: X isn't that hard after all. I'm sure there are all sorts of subtleties I've missed, but the result of what I have described here is a physical Linux machine that I can remotely administer, running Oracle 10g faster and more effectively than any of my virtual machines can do, but which is nevertheless as conveniently available to me as my own Windows desktop.
In fact, it is so readily available, and so convenient to get to, that I really don't need to run Oracle on my XP Desktop at all anymore, unless I am researching some Windows-specific quirk or functionality. Which means my desktop has more CPU cycles going free to service much more important things, such as games and music and DVD movies... you know, all the productive stuff in life!
I like the Cygwin X server very much, in short, and I think everyone should have one!

You can also in /etc/X11/fs/config, comment out this line:
# don't listen to TCP ports by default for security reasons
#no-listen = tcp
If xfs is already properly installed, then you can tell it to reload, as described above, or restart it like this:
/etc/rc.d/init.d/xfs restart

Add the server's IP and name to your hosts file
On Windows, the hosts file is found in C:\WINDOWS\system32\drivers\etc and is read-only.

On a UNIX machine the hosts file is in /etc/hosts. You can add this info to ~/.rhosts instead.
Edit the file and add something like:    # My Oracle server

Start service X Wndows and check applications that are running
XWin -query
XWin.exe :0 -query

Process to Start X Server
ssh -X -l oracle

To PSCP copy files over ssh
pscp D:\Linux_Patch_9204\* oracle@

From Cygwin
ssh oracle@ X
xhost +

More information