• Migrate between Ubuntu distro or change desktop environment?

    One of the most visible changes (but not the only one!) between different Ubuntu distro is the Desktop Environment.

    Looking at the official information page about Ubuntu derivatives we can see many distributions like Lubuntu, Kubuntu, Xubuntu and so on, all officially maintained by Canonical.

    The beauty of any linux distro is that you can customize it as you want. Ubuntu is shipped with Unity desktop environment, however if you want to test (or remove) another environment, it’s quite easy:

    Install Ubuntu Unity:
    sudo apt-get install ubuntu-desktop

    Remove Ubuntu Unity:
    sudo apt-get purge ubuntu-desktop

    Install LUbuntu LXDE:
    sudo apt-get install lubuntu-desktop

    Remove LUbuntu LXDE:
    sudo apt-get purge lubuntu-desktop

    Install Ubuntu GNOME:
    sudo apt-get install ubuntu-gnome-desktop

    Remove Ubuntu GNOME:
    sudo apt-get purge ubuntu-gnome-desktop

    Install KUbuntu KDE:
    sudo apt-get install kubuntu-desktop

    Remove KUbuntu KDE:
    sudo apt-get purge kubuntu-desktop

    Install XUbuntu XFCE:
    sudo apt-get install xubuntu-desktop

    Remove XUbuntu XFCE:
    sudo apt-get purge xubuntu-desktop

    Remember that when you install a desktop environment you normally install extra software like games, accessories, etc, therefore once you have removed one using the “purge” option, you can then run:

    sudo apt-get autoremove --purge
    To clean up all the extra software. This is because the extra software is not uninstalled when you uninstall the main environment.

    Another option is to skip the installation of extra software by slightly tweaking the command. For example to install KUbuntu KDE environment just add –no-install-recommends as shown below:

    sudo apt-get install --no-install-recommends kubuntu-desktop

    Finally I have noticed that even if you remove completely the desktop environment associated to your distribution (for example you remove Unity from Ubuntu) leaving another one installed, as soon as a new version of the distribution is available, the original desktop environment is installed and set as default again. Therefore I’ve learned that the best way to migrate your Ubuntu distribution to another distribution is to download and burn the ISO of the next version (or even the same version!) and launch the installer.

    LUbuntu installation screen

    LUbuntu installation screen

    As you can see from the screenshot, by using this method you can migrate your distribution to another, without worrying about losing your settings or reverting back to the original one.

  • Tutorial: how to automatically mount WebDAV shares at boot in Linux

    In Ubuntu (and Kubuntu or Lubuntu) you can quite easily access a WebDav (or WebDavs) share using the standard file manager: Nautilus, Konqueror or PcManFm.

    Just put in the address bar the site you want to open (for example: davs://yoursitename or webdav://yoursitename) and click on enter… That’s it (probably you will be asked for credentials – just put the right ones there…)!

    To make it work you only need to know if the connection is secure (davs) or not (webdav) and if the package davfs2 is installed (open a terminal and type “sudo apt-get install davfs2”).

    However in some cases you may want to have this share always mounted in your system and without the need to put credentials. If this is your case, the solution is pretty easy:

    Create a folder on your disk into which the web share will be mounted:
    sudo mkdir /mnt/sharename

    sudo nano /etc/davfs2/secrets

    add the line:
    https://www.yourshare.com username password

    and now you need to make sure the connection is made each time you start your computer:

    sudo nano /etc/fstab

    at the end of the file, on a new line type:

    https://www.yourshare.com/ /mnt/sharename    davfs   defaults,uid=username,gid=username,_netdev,auto  0       0

    Please note the options uid and gid, these are used to tell to the system which user will be able to write to the share (normally is root). In this case “username” is the one you use on your computer.
    The option “_netdev” tells to the system to wait for the connections to be up before attempting to mount the share (otherwise it will fail). The mount will happen automatically, as requested by the option “auto”.

    Incoming search terms:

    • auto mount webdav
  • Ubuntu: How to automatically launch scripts/software upon inserting USB devices

    Have you ever thought about performing a custom action or launch a specific software when plugging your favorite USB device on Ubuntu?

    USB Cable

    I’ve been investigating this possibility recently and I’ve found a quite satisfactory solution. The idea has born when reading this blog about how to read udev rules. Udev is the device manager introduced with Kernel 2.6.13 and it manages all the /dev devices dynamically. Using upstart rules, we can use specific files (rules) to tell to our OS that a specific action/script should be run when a device (or a specific device) is attached to the system. The files are

    So I thought that it would be good to launch a simple script when I attach my Palm Pre2 to my Ubuntu via USB and run a rsync that will maintain a local backup of my USB partition on the phone.

    Thanks to the work done at stackoverflow I was able to understand how to create the rules, tailoring them for my device and then use notify-send to have a graphical view of what the script is doing.

    First thing to do is to identify your device:

    launch from a terminal window the command: udevadm monitor –env

    This will monitor the ports of your machine and when you plug a device like an usb pen, you’ll see a few lines identifying different pieces of information.

    What you need to write down are: ID_SERIAL_SHORT, idVendor and product.

    For example our ID_SERIAL_SHORT can be something like: 156aab412740f93d04869cac6c0837229d48456e, the idVendor a small number like “8332” like the product “8045”.

    Now that we have this information, we can create our upstart rule by creating a file named like 91-backup.rules in /etc/udev/rules.d (please note that the file should start with two digits and having an higher number of the other files in the same directory, so you’ll be sure that it’s executed first).

    Mine looks like:

    SUBSYSTEM==”block”, ID_SERIAL_SHORT==156aab412740f93d04869cac6c0837229d48456e, NAME=”PALM PRE”, SYSFS{idVendor}=”8332″, SYSFS{product}=”8045″,

    RUN+=”/home/user/backup/copy.sh”

    Please note the last line that calls a specific script, but you can choose a software or anything else.

    In my case, the content of that “copy.sh” is:

    #!/bin/sh

    sleep 2 #wait for the system to mount the drive

     if [ -d /media/PALM PRE/ ] # if the drive has been mounted

    then

     su stefano -c “DISPLAY=”:0.0″ notify-send “Mount” “Palm_PRE2 ready” -t 2000 -i “/home/user/backup/pre.jpeg”” #show on the OSD a specific message with icon

     rsync -ru /media/PALM PRE/ /home/user/backup/PRE/ #do a backup of my external media using rsync

            su stefano -c “DISPLAY=”:0.0″ notify-send “Palm_PRE2” “Syncronization_complete” -t 2000 -i “/home/user/backup/images.jpeg”” #reports that the backup is completed on the OSD

    fi

    I hope that this information will help you in doing something similar (and useful!) on your system. Enjoy!