Archive for April, 2008

Get current date / time

A very useful function of the unix shell is the date function. It allows you to get the current system time in any format you need. Some examples:

date : returns the current date / time
date -u : returns the current UTC date / time
date +"%s" : returns the current date / time in unix timestamp format (seconds since the epoch)

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.

KDE start up applications

If you’re using KDE and wish to have applications launched automatically on start up, you simply need to add an application launcher in ~/.kde/Autostart/. A simple and clean way of achieving this is to create a symlink of the application in ~/.kde/Autostart/

For example, assuming you want Skype to startup automatically, execute the following:
ln -s /usr/bin/skype ~/.kde/Autostart/skype

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