Raspberry PI Adventures


raspberry_pi_logoIn this blog I will keep you informed about my Raspberry PI adventures!

You will find useful and interesting tips and tricks for beginning Raspberry PI users.

For questions and / or comments feel free to send an email to: moc.v1448857331edbew1448857331egac@1448857331ofni1448857331


  1. bind actions to (hot)keys?
  2. …open your Raspbmc favorites with one keypress?
  3. use your Android phone as a remote control for your Raspbmc Media Center?
  4. install Raspbmc Media Center on your Raspberry PI?
  5. …install OpenElec / XBMC Media Center on your Raspberry PI?
  6. …use Unix commands on your Raspberry PI?
  7. …run cool apps on your Raspberry PI?
  8. …show some system info with a Python script?
  9. …create a backup image of your SD card while your Raspberry PI is running?
  10. …play internet radio on your Raspberry PI?
  11. …take screenshots on your Raspberry PI?
  12. …execute a shell script on your Raspberry PI?
  13. …check your Raspberry PI’s file system?
  14. expand the root partition of your Raspberry PI’s SD card?
  15. send a boot email from your Raspberry PI?
  16. …access your Windows shares from your Raspberry PI?
  17. …update your Raspberry PI’s firmware?
  18. …list the installed packages on your Raspberry PI?
  19. …run Processing on your Raspberry PI?
  20. …add menu items to the start menu of your Raspberry PI?
  21. …add the PI Store to your Raspberry PI?
  22. duplicate your Raspberry PI’s SD-card?
  23. …to add a new shortcut to your Raspberry PI’s desktop?
  24. …get the audio working on your Raspberry PI?
  25. …use a remote desktop with your Raspberry PI?
  26. …play Flash movies (YouTube!) in Midori on your Raspberry PI?
  27. …create a simple Python web server on your Raspberry PI?
  28. …put your Raspberry PI in TURBO Mode?
  29. …mount your network drive on your Raspberry PI?
  30. remove applications from your Raspberry PI?
  31. …update the system software on your Raspberry PI?


Raspberry PI

Raspberry PI – binding actions to (hot)keys

Raspberry PI Logo
How to bind actions to Raspberry Pi (hot)keys?

I want to define a key for starting the lxterminal on my Raspberry PI.

This is how you can do it:

  • Open the LXDE configuration file:
    sudo nano ~/.config/openbox/lxde-rc.xml
  • In the <keyboard>(…)</keyboard> section add the following lines of code:
    <keybind key=”F4″>
      <action name=”Execute>
    <keybind key=”F5″>
      <action name=”Execute>
        <command>gksu /usr/bin/x-terminal-emulator</command>
  • Reboot the PI:
    sudo shutdown -r now

When it’s back up-and-running, pressing the <F4>-key will launch the LX Terminal and the <F5>-key will launch the Root Terminal.


Raspberry PI – Raspbmc – open your favorites with one keypress

How to open your Raspbmc favorites with one keypress?

  • navigate to the folder /home/pi/.xmbc/userdata/keymaps
  • edit a file called keyboard.xml (create one if it doesn’t exist yet!)
  • add the following text to the file:
    (of course you can replace <F1> by a different key)
  • Reboot the PI:
    sudo shutdown -r now

Now your ‘favorites menu’ will appear anytime you press your <F1>-key!

Raspberry PI – using your Android phone as a remote control for Raspbmc

How to use your Android phone as a remote control for your Raspbmc Media Center?

On your Android phone go to https://play.google.com/store/apps/details?id=org.xbmc.android.remote and install the Official XBMC Remote app.

Run the app and choose ‘Add new host‘.

Then you have to enter the local IP-address of your PI, for instance:
Port number: 80
Usercode: xbmc
Password: [empty]

After entering the new host info choose ‘Remote Control‘ and there you go!




Raspberry PI – installing Raspbmc media center

How to install Raspbmc Media Center on your Raspberry PI?

  • insert a SD-card in your reader
  • first click:
    ‘Restore SD card for formatting
  • then check ‘I accept the licence agreement’ and click:
  • take the card out of the reader, put it in your Raspberry PI and boot it (the installation will take quite a while, 20+ minutes!)
  • after the installation is done you will get the main XBMC screen, go to Settings > International and adjust your location / time zone

Useful resources:

Raspberry PI – installing OpenElec / XBMC media center

How to install OpenElec / XBMC Media Center on your Raspberry PI?

You can turn your PI into a Media Center for playing Music, Videos and showing Pictures using the OpenElec image.

Here’s how to install it.


  • if you want to make a ssh connection to your PI use: usercode = root; password = openelec (usercode and password cannot be changed!)
  • you cannot use any remote desktop with OpenElec (it doesn’t support X!)

To stream music, videos and pictures from your (SAMBA) network drive:

  • on the XBMC screen navigate to System > OpenElec > Services and ENABLE Samba

Great resources:

Raspberry PI – using Unix commands

How to use Unix on your Raspberry PI?

This will be a useful (growing) collection of Unix / Raspbian commands to use with your Raspberry PI.

  • get the current frequency of the RPi CPU:
    /opt/vc/bin/vcgencmd get_config arm_freq
  • measure the temperature of the RPi CPU:
    /opt/vc/bin/vcgencmd measure_temp
  • get the current firmware version of your RPi:
    /opt/vc/bin/vcgencmd version
  • find the MAC address of your RPi:
    cat /sys/class/net/eht0/address
  • show all mounts:
    df -h
  • show all installed packages:
    dpkg –get-selections
    find a specific package:
    dpkg –get-selections | grep <package name>
  • list all files in a directory (last modified files last):
    ls -lrt
  • check for distro upgrades for your RPi:
    sudo apt-get dist-upgrade
  • remove an (apt-get) application from your RPi:
    sudo apt-get –purge remove <app name> && sudo apt-get autoremove –purge
  • update your system software and remove orphans:
    sudo apt-get update && sudo apt-get upgrade && sudo apt-get autoremove –purge
  • switch to ‘super user‘ terminal window (means you don’t have to use the ‘sudo’ prefix in front of all the following commands)
    sudo -i
  • synchronize the date and time of your RPi:
    sudo dpkg-reconfigure tzdata
  • find the IP-address of your RPi:
    sudo ifconfig
  • list all loaded drivers:
    sudo lsmod
  • list all connected USB devices
    sudo lsusb
  • edit the Raspberry PI boot configuration file:
    sudo nano /boot/config.txt
  • change the system configuration of your RPi:
    sudo raspi-config
  • reboot your RPi:
    sudo reboot
  • list the most active system processes (quit by pressing ‘q’)

Raspberry PI – running COOL apps

How to run COOL apps on your Raspberry PI?

This will be a useful (growing) collection of interesting / useful apps to run on your Raspberry PI.


  • audio utilities for your PI:
    sudo apt-get install alsa-util
  • play mp3 files on your PI:
    sudo apt-get install mpg321
  • wav to mp3 converter:
    sudo apt-get install lame
  • play all kinds of media files on your PI using the VLC media player:
    sudo apt-get install vlc


  • libreoffice (a great opensource MicroSoft Office / Open Office clone):
    sudo apt-get install libreoffice-writer libreoffice-calc libreoffice-impress libreoffice-draw libreoffice-base libreoffice-math libreoffice-filter-mobiledev
    Just delete the modules you don’t want to install from the above list:
    libreoffice-writer: Word processor
    libreoffice-calc: Spreadsheet
    libreoffice-impress: Presentation
    libreoffice-draw: Drawing
    libreoffice-base: Database
    libreoffice-math: Equation editor
    libreoffice-filter-mobiledev: Mobile Devices filters
  • Chromium (Google web browser):
    sudo apt-get install chromium
  • Joe’s Editor: user friendly Unix text editor (my favorite!):
    sudo apt-get install joe
  • Midnight Commander (MC) is a “Swiss army knife” for the Linux console and other terminal environments
    sudo apt-get install mc
  • RDP remote desktop server for connecting to your PI remotely:
    sudo apt-get install xrdp

Raspberry PI – showing some system info with a Python script

How to show some system info with a Python script?

  • Create a Python script, for instance in a directory called /home/pi/Code (create the directory if it doesn’t exist yet):
    sudo nano /home/pi/Code/system_info.py
  • Add the following code to the file:
    import subprocess
    import os
    def get_ram():
        “Returns a tuple (total ram, available ram) in megabytes. See www.linuxatemyram.com”
            s = subprocess.check_output([“free”,”-m”])
            lines = s.split(‘\n’)       
            return ( int(lines[1].split()[1]), int(lines[2].split()[3]) )
            return 0def get_process_count():
        “Returns the number of processes”
            s = subprocess.check_output([“ps”,”-e”])
            return len(s.split(‘\n’))       
            return 0def get_up_stats():
        “Returns a tuple (uptime, 5 min load average)”
            s = subprocess.check_output([“uptime”])
            load_split = s.split(‘load average: ‘)
            load_five = float(load_split[1].split(‘,’)[1])
            up = load_split[0]
            up_pos = up.rfind(‘,’,0,len(up)-4)
            up = up[:up_pos].split(‘up ‘)[1]
            return ( up , load_five )       
            return ( ” , 0 )

    def get_connections():
        “Returns the number of network connections”
            s = subprocess.check_output([“netstat”,”-tun”])
            return len([x for x in s.split() if x == ‘ESTABLISHED’])
            return 0

    def get_temperature():
        “Returns the temperature in degrees C”
            s = subprocess.check_output([“/opt/vc/bin/vcgencmd”,”measure_temp”])
            return float(s.split(‘=’)[1][:-3])
            return 0

    def get_ipaddress():
        “Returns the current IP address”
        arg=’ip route list’
        data = p.communicate()
        split_data = data[0].split()
        ipaddr = split_data[split_data.index(‘src’)+1]
        return ipaddr

    def get_cpu_speed():
        “Returns the current CPU speed”
        f = os.popen(‘/opt/vc/bin/vcgencmd get_config arm_freq’)
        cpu = f.read()
        return cpu

    print ‘Free RAM: ‘+str(get_ram()[1])+’ (‘+str(get_ram()[0])+’)’
    print ‘Nr. of processes: ‘+str(get_process_count())
    print ‘Up time: ‘+get_up_stats()[0]
    print ‘Nr. of connections: ‘+str(get_connections())
    print ‘Temperature in C: ‘ +str(get_temperature())
    print ‘IP-address: ‘+get_ipaddress()
    print ‘CPU speed: ‘+str(get_cpu_speed())

  • Save the file and make it executable:
    sudo chmod +x system_info.py
  • Execute the script:
    python /home/pi/Code/system_info.py

There are many more system settings that could be added to the script! 😉

Raspberry PI – creating a backup image while the Raspberry PI is running

How to create a backup image of your SD card while your Raspberry PI is running?

You can create a backup (.img) of your SD card to a network / USB drive while the card is inserted in your Raspberry PI!

  • make sure you have access to your network drive / usb drive;
    to see the devices type:
    sudo cat /etc/fstab
  • create an img of the card currently in the PI to your network drive / USB drive using the dd command:
    sudo dd if=/dev/mmcblk0p2 of=/home/pi/networkdrive/my.img bs=1M
    (replace /dev/mmcblk0p2 with your own SD card and /home/pi/networkdrive/my.img with your own network drive / USB drive + image file name)

Good luck!