Archive for the 'packages' Category

.php with PHP5 in Apache

Usually, when an Apache web server supports PHP4 and PHP5, the default configuration is .php scripts are handled with PHP4, and .php5 scripts with PHP5 . You can however specify that .php scripts should be handled with PHP5 instead.

To achieve that, you should modify the .htaccess file by adding the following:
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4

The new handling will apply to all .php scripts in the current directory and it’s sub-directories. PHP4 will looks for the .php4 extension in this case. Note that the second line is necessary, otherwise a handling conflict will occur.

SSH Socks Tunnel

SSH can be used to tunnel a connection from one computer to another. That is when you access the internet from computer A, it will seem like you are accessing it from computer B. This is useful for bypassing the restriction on content imposed from computers in schools, coffee shops, or companies. You can also benefit from the services offered in one specific network.

From a unix environment, simply execute the following replacing username and server by the appropriate values. This will create a SOCKS proxy on port 3333 (you can of course use another port):
ssh -D 3333 -f -C -q -N username@server

Now, you just need to modify your browser preferences to use that proxy and you’re done. In Firefox, head to preferences and find the connection settings. Use manual proxy configuration, and enter in the SOCKS proxy field localhost on port 3333.

Setup SSH Server

Installing SSH server on your machine is quite straight forward. This will enable you to access your data from any SSH client.

Simply install the required packages as follows:
sudo apt-get install openssl ssh

You can now access your computer from another machine using an SSH client. From another linux machine, you could access it using the following format:
ssh username@machine

SSH behind router
If you’re using a router, and would like to SSH your computer from an external network, you should configure your router to forward the SSH port (default: 22) to the computer in question. This procedure differs from a router to another; look for ‘Port Forwarding’ in the configuration menu of your device.

SSH without a password
This is extremely useful if you don’t want to type your password from the client every time you SSH, of if you are automating SSH login. The process is described on SSH Without a Password.

Screen resolution in rdesktop

You can remote desktop a Windows machine from Linux using the exquisite rdesktop command-line application; an example:
rdesktop [machine]
You can replace [machine] by the host name on the network or the IP address.

Now, if you want to open the screen at a specific resolution, for example 1280×1024 resolution, add the -g flag:
rdesktop -g 1280x1024 [machine]

Mount a CD image to a directory

ISO CD images
Mounting a CD image in ISO format (eg. image.iso) is quite straightforward. Just execute the following in the terminal:
sudo mkdir /media/iso
sudo mount -t iso9660 -o ro,loop image.iso /media/iso

Other CD images
For other types of CD images such as NRG, BIN/CUE, MDF, CDI, CCD/IMG or C2D; you should first convert them to ISO and then mount them as described above. Fortunately, a nice and neat application exists for that purpose: KIso.

  1. First, install KIso by executing the following:
    sudo apt-get install kiso
  2. Open KIso by running sudo kiso. Now click on CD Image -> Convert Image and select the image (eg. image.bin) to convert.
    Convert image using KIso
  3. An ISO version of the image (image.iso) is now available in the original image’s directory. You can now execute the procedure described in ISO CD images.

Send and receive files via Bluetooth

Using Bluetooth, you can transfer data to basically any other desktop or mobile (particularly phones) device having a Bluetooth interface. Doing so in Ubuntu is a simple operation once you’re finished with the configuration.

Configuration

  1. First install the required packages from the shell by executing:
    sudo apt-get install gnome-bluetooth bluez-utils
  2. Make sure the Bluetooth adapter is enabled on your machine. That is make sure your USB adapter is connected, or the Bluetooth switch on your laptop is set on. To be certain, you can execute hcitool dev which will tell you if any Bluetooth interfaces exist on your machine.
  3. Now restart the Bluetooth interface by executing:
    sudo /etc/init.d/bluetooth restart
  4. Enable the Bluetooth File Sharing service by simply executing it from the Gnome menu. It can be found under Applications -> Accessories -> Bluetooth File Sharing. This will start gnome-obex-server which allows you to receive files as well as facilitates the sending operation.
    Bluetooth File Sharing

Receiving a file
Once the configuration completed, you’ll be able to receive files via Bluetooth.

  1. You just need to make sure your interface is visible so that other devices can find you. Visibility can be configured in the Bluetooth Preferences which can be found under System -> Preferences -> Bluetooth Preferences. Set the Mode of operation to Visible and connectable for other devices.
  2. Your machine is now discoverable, and external devices are able to send you data. Once you receive a file, a window will popup to notify you this is the case.
    Receiving a file via Bluetooth
  3. You are advised to change back the visibility settings once the transmission is complete.

Sending a file
Bluetooth File Sharing makes it quite easy to send data accross Bluetooth. Simply right click on the file you wish to send, then select Send to.... In the new window:

  • Set the Send as field to Bluetooth (OBEX Push)
  • Set the Send to field to destination Bluetooth device
  • Click Send and you’re done!
    Send a file via Bluetooth

Alternative method to send files using the shell:

  1. Execute hcitool scan to scan for Bluetooth devices within range. Something similar will be displayed:
    Scanning ...
    00:11:24:B1:11:05 iMac G5
    00:11:9F:BE:47:CB michael-phone

    The hexadecimal series (eg. 00:11:9F:BE:47:CB) displayed near the device name (eg. michael-phone) is the mac address associated with the Bluetooth device.
  2. Send the file by executing the following (replace the file and the mac address appropriately):
    gnome-obex-send sample/file.txt --dest=00:11:9F:BE:47:CB

Browse unix man pages

Navigating in a man page (accessed through the man command) can be annoying particularly if you’re going through 5 pages of text or else. man2html is a small but useful tool that makes the unix man pages available in your web browser with a simple and clean interface.

  1. First install man2html from the shell by executing:
    sudo apt-get install man2html
  2. Then to view your man pages, just point your browser to:
    http://localhost/cgi-bin/man/man2html

Running Windows XP on VMware Player

The main reason limiting individuals from moving permanently from Windows to Ubuntu is the lack of support for numerous software applications. Fortunately, this reality is changing because of the growing Ubuntu community contributing to the process through developing Open Source alternatives, and the expansion of the Linux market attracting the attention of proprietary application developers.

Although some applications run quite smoothly through the excellent Wine package, others cause much trouble and you just need to run Windows in order to get the job done. Thanks to virtualization and VMware Player, a completely free application, you can now run Windows XP directly within your Ubuntu system. Note that this process might take some time but is worth it (take a look below). Let’s get started!

Running Ubuntu and Windows XP on two screens

  1. Install, at once, all the prerequisite packages. Run in the shell:
    sudo apt-get install build-essential linux-headers-`uname -r` gcc-3.4 g++-3.4 wine
  2. Download VMware Player for Linux (make sure you get the .tar version) and install it as follows:
    tar xvzf VMware-player-2.0.2-59824.i386.tar.gz
    cd vmware-player-distrib
    export CC=/usr/bin/gcc-3.4
    sudo ./vmware-install.pl

    The default choice for all prompts should be ok.
  3. We will now create a file partition for Windows XP (Steps 3 to 5). To do so we’ll need to run Qemu, a process emulator, through Wine. Proceed as follows:
    Download Qemu for Windows and install it with Wine
  4. Create a directory to store all our data in:
    mkdir ~/winxp
    cd ~/winxp
  5. Now, create the file partition; you can set the amount of diskpace allocated to Windows XP by changing 10G (that’s 10 Gigabytes) to whatever you need:
    wine ~/.wine/drive_c/Program\ Files/Qemu/qemu-img.exe create -f vmdk WindowsXP.vmdk 10G Formating 'WindowsXP.vmdk', fmt=vmdk
  6. Let’s now create an ISO image of Windows XP. Insert the installation CD and execute:
    umount /media/cdrom0
    dd if=/dev/cdrom of=WindowsXP.iso
    This will create a file called WindowsXP.iso; be patient, it might take some time to complete (took me about 4 minutes).
  7. Create the VMware player configuration file:
    gedit WindowsXp.vmx
    Fill in the following content and save the file. You can set the amount of RAM to be used by changing the memsize value.
    #!/usr/bin/vmware
    config.version = "8"
    virtualHW.version = "3"
    ide0:0.present = "TRUE"
    ide0:0.filename = "WindowsXP.vmdk"
    memsize = "256"
    MemAllowAutoScaleDown = "FALSE"
    ide1:0.present = "TRUE"
    ide1:0.fileName = "WindowsXP.iso"
    ide1:0.deviceType = "cdrom-image"
    ide1:0.autodetect = "TRUE"
    floppy0.fileType = "file"
    floppy0.fileName = ""
    floppy0.startConnected = "True"
    ethernet0.present = "TRUE"
    usb.present = "TRUE"
    sound.present = "TRUE"
    sound.virtualDev = "es1371"
    displayName = "Windows XP"
    guestOS = "winxp"
    nvram = "WindowsXP.nvram"
    MemTrimRate = "-1"
    ide0:0.redo = ""
    ethernet0.addressType = "generated"
    uuid.location = "56 4d cd 3f 59 5b 61 43-fd 73 ef 46 56 4c 23 7b"
    uuid.bios = "56 4d cd 3f 59 5b 61 43-fd 73 ef 46 56 4c 23 7b"
    ethernet0.generatedAddress = "00:0c:29:4c:23:7b"
    ethernet0.generatedAddressOffset = "0"
    tools.syncTime = "TRUE"
    ide1:0.startConnected = "TRUE"
    uuid.action = "create"
    checkpoint.vmState = "WindowsXP.vmss"
    tools.remindInstall = "TRUE"
  8. Run WindowsXp.vmx through VMwarePlayer (double clicking on the file will do), and go through the Windows XP installation, this might take anything from 15 min to 1 h depending on your system specifications.
    Installing Windows XP

Some time later… after installation is completed, you’re done! You can now launch Windows Xp from Applications -> System Tools -> VMWare Player and the speed is almost similar to that of running it as a main operating system.

This tutorial is partly based on dryandplain’s HOWTO on Ubuntu Forums.

Slow Booting Up?

I’m running Ubuntu on a quite descent laptop configuration. Up to now, Ubuntu’s booting was taking around 3 minutes, a bit too long. After some analysis and research, I was able to reduce that to under 35 seconds. If you’re having a similar problem, the following procedure might be helpful.

  1. Install bootchart, a cool small application that allows you to see what’s happening on boot time.
    Type the following in the shell:
    sudo apt-get install bootchart
    This will create on each boot a log image in /var/log/bootchart/
    describing the runtime booting processes.
  2. Reboot your machine and check the created log image. In my case, the boot sequence looked as follows:
    Previous Booting Sequence
    Booting was taking 177 seconds.
  3. Analyse the log. We notice that usplash, a user application that draws a splash screen on boot (thus dispensable), seems to be consuming way too much CPU time, and for too long. A search on Ubuntu forums shows that usplash is a bit buggy, and that this boot problem is quite common.
  4. Disable the concerned process. For usplash, the following will do:
    sudo apt-get remove usplash
    Now reboot, and check the new created image log. In my case, it looks like that:
    Check Post-Mod Boot Sequence
    Down to 31 seconds!
  5. Remove bootchart if you don’t need it any longer, otherwise a log will be created on each boot. Execute:
    sudo apt-get remove bootchart

Important note: Don’t try to be smart and disable all boot processes (just in case you were thinking about that!). Make sure you know what you’re doing.

Installing Eclipse Europa

Eclipse is a development platform for Java, C++ (or any other language throught the use of plugins), originally created by IBM (but later released as an open-source project). Eclipse Europa (v 3.3.1.1 at the time I’m writing this article) is not included yet in the Ubuntu source repositories, that means that you cannot install it *properly* through the Synaptic Package Manager or apt-get. Follow this simple tutorial for a smooth and clean installation:

Eclipse Europa

  1. Install the Java 5 runtimes (or later) in case they’re not there already. Run the following in the terminal:
    sudo apt-get install sun-java5-jre
    sudo apt-get install sun-java5-jdk
  2. Download the latest release of Eclipse Classic available on Eclipse Downloads
  3. Extract the downloaded file by running the following:
    tar xzf eclipse-SDK-3.3.1.1-linux-gtk.tar.gz
    sudo mv eclipse /opt/

    Take care of the permissions:
    sudo chmod -R +r /opt/eclipse
    sudo chmod +x /opt/eclipse/eclipse
  4. Create an executable in your path:
    sudo touch /usr/bin/eclipse
    sudo chmod 755 /usr/bin/eclipse
    sudoedit /usr/bin/eclipse

    Copy the following content and save the file:
    #!/bin/sh
    #export MOZILLA_FIVE_HOME="/usr/lib/mozilla/"
    export ECLIPSE_HOME="/opt/eclipse"
    $ECLIPSE_HOME/eclipse $*

    Let’s also make eclipse executable everywhere by creating a symlink:
    sudo ln -s /usr/bin/eclipse /bin/eclipse
  5. Create the menu icon
    sudoedit /usr/share/applications/eclipse.desktop
    Type in this content and save:
    [Desktop Entry]
    Encoding=UTF-8
    Name=Eclipse
    Comment=Eclipse IDE
    Exec=eclipse
    Icon=/opt/eclipse/icon.xpm
    Terminal=false
    Type=Application
    Categories=GNOME;Application;Development;
    StartupNotify=true
  6. Run for the first time
    eclipse -clean
    You can now start Eclipse by simply typing eclipse in the terminal or from the GNOME menu Applications -> Programming -> Eclipse

Troubleshoot

  • Error java.lang.ClassNotFoundException: org.eclipse.core.runtime.Plugin
    This happens if Eclipse is using GNU Java runtimes instead of the Sun one’s. To correct this problem, execute the following:
    update-java-alternatives -l
    sudo update-java-alternatives -s java-1.5.0-sun

Part of the tutorial is based on Ivar’s How to install Eclipse in Ubuntu.