Thursday, 29 May 2008

Viewing display on remote computer on Ubuntu

If you want to use two computers using one screen, keyboard and mouse without using a KVM switch you can use Linux to output the display of one computer onto another.

This method should only be used on a secure network behind a firewall as stated in the documentation:
XDMCP service should run only on trusted networks and you have to disable firewall for interfaces, where you want to provide this service.
Any computer in the local network will be able to access the computers display so it is important you trust every computer.

To start with you need to edit the computer you want access to. As root edit the file /etc/sysconfig/displaymanager. Change the line:
DISPLAYMANAGER_REMOTE_ACCESS="no”
To:
DISPLAYMANAGER_REMOTE_ACCESS="yes”
Save the file and exit. You now need to restart XDMCP by typing:
rcxdm restart
Now any computer on the network can gain access to the display of this computer. To gain access use the command on the remote computer:
X :1 -query <IP address of first computer>
If everything has worked the login screen of the remote computer will load. You can switch back to your own computer’s display by pressing ctrl+F7 and then go back to the external computer again by pressing ctrl+F8.

If ctrl+F8 doesn’t work then try some other F keys, it’ll be in one of them.

Wednesday, 28 May 2008

Getting Minicom to work

When running Minicom for the first time you’re likely to be greeted with the following error message:
minicom: cannot open /dev/modem: No such file or directory
This is because Minicom is looking for your serial port in /dev/modem and in newer versions of Linux it’s located in /dev/ttyS0 or /dev/ttyS0. In the following example I will use /dev/ttyS0.

There are two ways to fix this problem. You can either create a shortcut of /dev/modem to point at /dev/ttyS0 or edit Minicom’s settings to use /dev/ttyS0.

To use the shortcut method use the following command:
ln -s /dev/ttyS0 /dev/modem
To edit Minicom’s settings start Minicom with the command:
minicom -s
This will open Minicom with the configuration menu. Use your direction key to scroll down to Serial port setup and press enter. Now press a to edit the Serial Device. Change this to be /dev/ttyS0. Press enter once you have finished editing. Now press escape to go back to the main menu. Finally select Save setup as dfl to make sure that the serial port is correct every time you run Minicom. You can now select Exit to start using Minicom or Exit from Minicom to close Minicom. In the future you can run Minicom without the -s flag

Saturday, 10 May 2008

Changing the display manager

If you wanted to change the display manager you could try stopping the current one and starting the one you want. For instance, if you wanted to stop using kdm (KDE desktop manager) and start using gdm (Gnome desktop manager) you might try the following:
/etc/init.d/kdm stop
/etc/init.d/gdm start
However, this gives an error along the lines of:
Not starting GNOME Display Manager (gdm); it is not the default display manager
To make gdm the default display manager you need to edit the file /etc/X11/default-display-manager. This file should only contain one line - the full path to the desktop manager you want to run. In the previous example the file would contain /etc/init.d/kdm. So I would change it to /etc/init.d/gdm. Now when you type the original commands the Gnome desktop manager will start.

Thursday, 8 May 2008

Calculating percentages in bash

Dividing in bash will cause problems if the result is below zero. This is a problem when you’re trying to work out percentages. For example, if you simply want to divide 1 by 2 the result should be 0.5. However, bash returns the result 0:
user@computer:~> echo $(( 1 / 2 ))
0
To fix this problem use the program bc, “an arbitrary precision calculator language”. Using bc you can do the calculation to a specified number of decimal places:
user@computer:~> echo “scale=2; 1 / 2″ | bc
.50
You can use this to work out the percentage as follows:
user@computer:~> echo “scale=2; 1 / 2 * 100″ | bc
50.00
To chop off the decimal places use sed:
user@computer:~> echo “scale=2; 1 / 2 * 100″ |  bc  |  sed s/\\.[0-9]\\+//
50