Donnerstag, 10. Oktober 2013

Install and update to latest Intel driver in Ubuntu (without PPAs)

If you are running a Laptop with integrated Intel graphics, it's pretty easy to update your drivers to the latest stable version, without running a PPA. You can easily build and install the driver on your own:
  1. Get the necessary dependencies:

    sudo apt-get build-dep xserver-xorg-video-intel

  2. Download the driver version you want to install (either stable tagged or git) from:

    http://cgit.freedesktop.org/xorg/driver/xf86-video-intel/

  3. Now (extract the archive and) open a terminal in the folder
  4. Set the x64 library path:

    export PKG_CONFIG_PATH=/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH

    This is necessary to otherwise the configuration step will fail.

  5. Configure everything to set install path to /usr:

    ./autogen.sh --prefix=/usr

  6. Build the driver:

    make

  7. Install the newly build driver to /usr:

    sudo make install

  8. Reboot and check whether new driver is installed and looking into:

    /var/log/Xorg.0.log

    Search for 'LoadModule: "intel"' (without ''). Three lines below you find your actual running driver version.
Beware: This will overwrite your actual installed driver. To revert to your previous driver (in case of problems), just reinstall it via: sudo apt-get install --reinstall xserver-xorg-video-intel

Dienstag, 17. September 2013

Build and install latest PostGIS in Ubuntu Linux

If you need to stick with the latest PostGIS version for your PostgreSQL-database, you either have to find a suitable PPA or simply build the extension yourself, because Ubuntu's PostGIS version is out-of-date. Instead of using 3rd party PPAs, I recommend to build it yourself the following way:

  1. Install the prerequisite packages:

    sudo apt-get install packaging-dev postgresql postgresql-server-dev-9.1 libxml2-dev libgeos-dev libproj-dev libgdal-dev

  2. Download the sources (e.g. for PostGIS 2.1.0):

    wget http://download.osgeo.org/postgis/source/postgis-2.1.0.tar.gz

  3. Extract the sources and go into extraction folder:

    tar xvzf postgis-2.1.0.tar.gz; cd postgis-2.1.0

  4.  Configure the sources

    ./configure

  5. Compile PostGIS

    make

  6. Install the compiled PostGIS extension

    sudo make install

  7. Use PostGIS within PostgreSQL:

    CREATE EXTENSION postgis;
     
Now you can build and control the update of your PostGIS versions by yourself.

Freitag, 6. September 2013

Process PostgreSQL data in R with Ubuntu Linux 12.04

Here is the ultimate overview  for all who like to work with R in Ubuntu and who want to process data from PostgreSQL. As a requirement, I assume that you already setup your PostgreSQL database.


  1. Step: Install dependencies (PostgreSQL, JDBC-Connector for PostgreSQL and R)
    sudo apt-get install postgresql libpostgresql-jdbc-java r-base-core r-cran-rjava r-cran-dbi 
  2. Step: Open Terminal & run R with
    R
  3. Step: Install JDBC-Package (RJDBC) for R
    install.packages(c("RJDBC"))
  4. Step: Connect to your database from within R
    # Include JDBC package
    library(RJDBC)

    # Initialize JDBC PostgresSQL driver
    drv <- JDBC("org.postgresql.Driver", "/usr/share/java/postgresql-jdbc4-9.1.jar", identifier.quote="`")

    # Establish connection to database
    conn <- dbConnect(drv, "jdbc:postgresql://localhost/database", "user", "pw")
    # Run your SQL select query
    data <- dbGetQuery(conn, "select * from iris where Species='setosa'")
  5.  That's it :) 
If you want to connect a non-local database, you have to adjust your dbConnect-command.

Donnerstag, 29. August 2013

Create Virtual Machine with Windows Guest using Qemu/KVM in Ubuntu Linux


I think Qemu/KVM represents a nice native alternative to Virtualbox or similar. Although all the GUI-tools (like aQemu or Qtemu) are broken in Ubuntu 13.04, it's really easy to setup a VM using the terminal. Precisely, you only need 3 commands to get a running VM:

  1. Create an image, where your VM is installed in. For Windows (>XP) take at least 18Gb:

    qemu-img create -f qcow2 ~/VMs/Windows\ 7/Windows\ 7.qcow2 18G

  2. Install your preferred OS in the created image:

    qemu-system-x86_64 -hda ~/VMs/Windows\ 7/Windows\ 7.qcow2 -cdrom ~/windows7_image_x64_.iso -boot d -m 4096 -cpu kvm64,+nx -enable-kvm

    Explanation for the parameters:
    This launches the typical Windows installation, whereas your new image represents your HDD to install to and -cdrom sets your installation media. The -boot parameter ensures that your VM boots the proper partition (you might can leave it out) and the option -m reserves 4096MB RAM for your VM (adapt it to your system). The -cpu parameter ensures that a 64-Bit CPU is emulated, because it's a KVM CPU you have to enable KVM in Qemu too.
    Note: Adapt the options to your system, especially in case your x86 user!
     
  3. After installation completed, launch your VM with:

    qemu-system-x86_64 ~/VMs/Windows\ 7/Windows\ 7.qcow2 -m 4096 -vga std -enable-kvm -cpu kvm64,+nx

    Of course you need to define the CPU again, enable KVM and set the memory. The option -vga std enables more and higher resolution within your VM, so use it if your are unsatisfied with low resolution.
     
That's it ! Of course you can also Linux VMs with it.

Two additional tips:
  • If your mouse pointer is caged within VM, free it with LEFT-[CTRL]+[ALT]
  • You can reach your Host from the Guest from the IP 10.0.2.2. This might be handy for web developers.

Dienstag, 27. August 2013

Enable Cover-Preview for Audio Files for KDE's Dolphin in Kubuntu 13.04


Unfortunately cover art preview is still not included in KDE (see Bug-report), you can enable that feature by yourself by building and installing the Preview Plugin of RazrFalcon from kde-look.org.

So, if you ever wanted a cover art preview for audio in Dolphin, e.g. like Nautilus has, here's my guide to make it work in Kubuntu (13.04):


  1. Install the necessary dependencies for building:

    sudo apt-get install cmake automake kde-workspace-dev libtag1-dev libqt4-dev libflac++6 libflac++-dev libtag-extras-dev

  2. Get the sources of the plugin:

    wget http://kde-look.org/CONTENT/content-files/145088-AudioThumbs-0.2.tar.gz

  3. and create a folder for it to unpack it:

    mkdir ~/audiothumbs;
    tar -zxvf 145088-AudioThumbs-0.2.tar.gz -C ~/audiothumbs


  4. Cd into the folder with sources and create a build dir and cd into it:

    cd ~/audiothumbs; mkdir build; cd build

  5. Now prepare building with cmake:

    cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..

  6. Finally compile it with:

    make

  7. and install it with:

    sudo make install

  8. Update KDE's settings to find the new plugin:

    kbuildsycoca4

  9. End all open Dolphin windows and reopen it. Go to "Control -> Configure Dolphin... -> General -> Previews" and enable "Show previews for Audio files"

  10. Now move to your folder with music and enable preview for the folder and enjoy the cover art in dolphin

Dienstag, 20. August 2013

Completely encrypt your external HDD / USB-Key securely using Ubuntu Linux


If you ever wondered how to encrypt some external devices in Ubuntu or Linux in general, the following commands will guide you:

1. Create a crypted LUKS container for your device (replace /dev/xxx with your device):    

sudo cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 --iter-time 5000 --use-random --verify-passphrase luksFormat /dev/xxx

You can also spare the additional parameters, cryptsetup will fall back on the default  parameters. Further explanation of what each parameter means can be found here.  

2. Open you encrypted container:    

sudo cryptsetup luksOpen /dev/xxx crypt_container    

3. Create a file system within the opened container (e.g. ext4):

sudo mkfs.ext4 /dev/mapper/crypt_container


4. Close the container and unmount it:    

sudo cryptsetup luksClose crypt_container     
sudo umount /dev/xxx    

That's it. Finally, if you disconnect and replug you device, Dolphin or Nautilus  will ask you for you password and mount it as every standard device.   If you need to check your new encrypted device or partition for errors, read this.

Donnerstag, 15. August 2013

Create *.po translation files from Vala Sources with context information in Ubuntu / Linux

I recently tried to create a *.po-File for translations strings from Vala sources which include locale context information.
As it was not so easy to figure out the right command, I thought I would share it with the internet folks:

xgettext -o result.po -L C -k_ --keyword=C_:1c,2 src/*.vala

So how does this work ?
  • xgettext extracts the translatable strings from the sources 
  • ...and puts it into the output file (-o result.po)
  • ...it also requires a defined programming language in this case C (-L C)
  • ...and needs to know what are translatable keywords (_ for strings and C_:1c,2 for contextual information, in this case)
  • ...finally set the input files (src/*.vala)
It's not that hard if you understand how it works :)

Dienstag, 9. Juli 2013

Build Umbrello UML modeler from Git in K/Ubuntu 13.04

Umbrello is a neat KDE-tool to create UML diagrams. If you want to test the latest code, why not get the git version ?


Here's a small guide to build compile latest umbrello from git:

  1. Get prerequisites:

    sudo apt-get install cmake make kde-workspace-dev libboost-all-dev libxml2-dev git-core

     
  2. Get source from git:

    git clone git://anongit.kde.org/umbrello

  3. Configure umbrello:

    cd umbrello; cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix`

  4. Compile it:

    make

  5. Install it:

    sudo make install


Want to run dev version in parallel with the stable version ? No problem just change cmake according to the Umbrello FAQ


Montag, 8. Juli 2013

Download all PDF files from Springer Link or other websites in Ubuntu using wget



As a regulary visitor of Springer Link I was always bored to download every single chapter of a publication. So I put together a small wget-comment which allows me to automatically download multiple PDF files from a webpage:


wget -nd -e robots=off --wait 0.25 -r -A.pdf http://yourWebsite.net/


The option -nd stands for no-directories, which means no directories are downloade and -e robots=off forces to not download the robots.txt, because we only want PDFs. The wait command ensures that failed downloads are retried after 0.25 seconds. Additionally I use the r parameter to get PDFs from subpages recursively and -A.pdf to get PDF files only.

Got improvements ? Leave a comment !

Donnerstag, 4. Juli 2013

Kubuntu 13.04 - Enable proper auto spell-checking in KDE

Unfortunately Kubuntu does not install the required packages to enable proper application-wide spell-checking. Here is a guide to enable auto spell-checking for all applications in Kubuntu.

1. Install the required packages ($lang is your language shortcut, e.g. en or de):

sudo apt-get install kde-l10-$lang language-pack-kde-$lang aspell-$lang hunspell-$lang

2. Setup and enable auto spell-checking in KDE:


 Open the KDE system settings and go to Locale


There select Spell Checker and enable Automatic spell checking enabled by default and check your default language (in this case German (Germany)). If you finished set confirm with Apply.

In some applications spell-checking is now enabled by default, like LibreOffice Writer in other you have to enable it, like KMail (New Message -> Right-Click).

Enjoy !

Mittwoch, 26. Juni 2013

Convert APE to FLAC in Ubuntu 13.04 using Libav

If you have a file in the lossless APE format and want to convert it without installing the MAC codec, you can easily do this in Ubuntu using Libav.

Just install av tools:

sudo apt-get install libav-tools

and convert the your file/s:

avcon -i inputApeFile.ape outputFlacFile.flac


That's one easy of many ways to convert APE files in Ubuntu.

Freitag, 21. Juni 2013

Reset Ubuntu Home Dir Permissions

In case you messed up the permissions of you home dir. Here is a small guide to fix it:

1. Reset the permissions for the directories recursivly:

sudo find /home/user/ -type d -exec chmod 755 {} \;

2. and the permissions for all files too:

sudo find /home/user/ -type f -exec chmod 644 {} \;

3. Ensure that your GPG directory has the proper permissions:

sudo chmod -R 600 .gnupg/
sudo chmod 700 .gnupg/

If you don't want that other users can read your home folder (which not default in Ubuntu) change it's permission also:

sudo chmod 700 /home/user

That's it. Not that hard, if you know the right commands.

Mittwoch, 12. Juni 2013

Check MD5 and SHA1 sum for a file in Ubuntu Linux

Imagine you have a file to download with a given checksum and you want to make sure that the file is not corrupted after download.



It's really easy to compute and check the MD5 sum in Ubuntu / Linux using the terminal:

md5sum myFileToCheck

and for SHA1 checksum:

sha1sum myFileToCheck
Both commands compute the corresponding checksum of your file, so you can compare than with the original checksums.

Donnerstag, 30. Mai 2013

Check and repair LUKS encrypted partitions in Ubuntu 13.04

Unfortunately Gnome Disks was castrated in version 3.6, it is now impossible to repair LUKS encrypted filesystems with the help of Gnome Disks. But you can easily do this within the terminal.

If you are using a LUKS encrypted partition and you want to check whether it has file system errors, you can do this with the following commands:

  1. Mount and open your LUKS partition:

    sudo cryptsetup luksOpen /dev/<yourPartition> <someMountName>

    e.g.: sudo cryptsetup luksOpen /dev/sdb3 foo
  2. Run fsck on it to check and auto-repair the filesystem:

    sudo fsck -a /dev/mapper/<someMountName>

    e.g.:  sudo fsck -a /dev/mapper/foo
  3. After the check / repair is finished, do not forget to close your LUKS volume again:

    sudo cryptsetup luksClose <someMountName>

    e.g. sudo cryptsetup luksClose foo
If you want to avoid an auto-repair and instead want to do a user guided check / repair, just remove the "-a" option.

That's it easy peasy, isn't it ?

Freitag, 24. Mai 2013

Install latest Homerun version in Kubuntu 13.04

Install latest Homerun version in Kubuntu 13.04



Just a small tutorial how to build and install the latest version of Homerun in Kubuntu 13.04 as the PPA is slightly outdated:
  1. Get the latest stable release and extract it or get the git snapshot (via git clone git://anongit.kde.org/homerun)
  2. Install necessary dependencies: 

    sudo apt-get install libkonq5-dev kde-workspace-dev kdelibs5-dev
  3. Go into folder:

    cd homerun

  4. Create build directory and go into it:

    mkdir build; cd build
  5. Build it:

    cmake -DCMAKE_INSTALL_PREFIX=`kde4-config --prefix` ..

  6. Compile it:

    make
  7. Install it:

    sudo make install
  8. If you already run an older version of Homerun killit and restart homerun:killall homerunviewer; homerunviewer

There we go ! You can easily remove it via sudo make uninstall from install dir.

Donnerstag, 2. Mai 2013

R mit PostgreSQL unter Ubuntu 12.04

Hier die ultimative Übersicht für alle die gerne mit R unter Ubuntu arbeiten und Daten aus PostgreSQL verwenden möchte. Ich geh davon aus, dass die PostgreSQL-Datenbank jeder allein einrichten kann.


  1. Schritt: Abhängigkeiten (PostgreSQL, JDBC-Connector für PostgreSQL und R) installieren
    sudo apt-get install postgresql libpostgresql-jdbc-java r-base-core r-cran-rjava r-cran-dbi 
  2. Schritt: Terminal öffnen & R starten mit
    R
  3. Schritt: JDBC-Paket (RJDBC) für R installieren
    install.packages(c("RJDBC"))
  4. Schritt: Verbindung zur Datenbank aus R herstellen
    # JDBC-Paket einbinden
    library(RJDBC)

    # JDBC-PostgresSQL-Treiber initialisieren
    drv <- JDBC("org.postgresql.Driver", "/usr/share/java/postgresql-jdbc4-9.1.jar", identifier.quote="`")

    # Verbindung zur Datenbank herstellen
    conn <- dbConnect(drv, "jdbc:postgresql://localhost/datenbank", "user", "pw")
    # SQL-Query ausführen
    data <- dbGetQuery(conn, "select * from iris where Species='setosa'")
  5.  Fertig :) 
Bei Verbindungen zur nicht lokalen Datenbanken muss der dbConnect-Aufruf angepasst werden.