Restore Zimbra, OSE, from backups
30 Mar

Restore Zimbra, OSE, from backups

This morning I thought to take advantage of the long weekend and update my Zimbra installation – this didn’t go as well as expected. Instead I ended up with a corrupted server. I was left spending the morning restoring from my latest backup.

The process was simple enough, but since I couldn’t find a clear step-by-step guide I thought having an easy to find reference guide would be of use in the future – as I’m sure I’ll be in a simliar possition again one day. Read more »

Rsync Bandwidth Limit
02 Aug

Rsync Bandwidth Limit

How do I stop Rsync using all my bandwidth?

If you use rsync to move large or just a large number of files from one machine to another, ether over the internet or your local network, you’ll have realised rsync uses as much bandwidth as it can get a hold of which is not always convenient.

The reason you might want to reduce rsync’s bandwidth load is to ensure it doesn’t clog up you network making everything else unusable.

Obviously this is going to slow down to total time require to transfer your files. On the face of it this might not seem ideal, but if your moving your nightly backup files from your webserver to your backup location time isn’t the most important factor. What you really want is these backups to happen seamlessly in the background and not to DDOS your own site.

A normally rsync command might look something like this:

The parameter that tells rsync how much bandwidth to use is --bwlimit.

So if you want to limit rsync to 10MB a second the command would look like:

Or to limit rsync to 5MB a second the command would look like:

Samba Full Audit Trail
19 Jul

Samba Full Audit Trail

This is a new one. I was asked today by someone to explain why files were missing from the Samba file server. Sadly in the end I wasn’t able to find out why simple because there was no log. This at least isn’t a case of a system admin not keeping logs, there were thousands of them for Samba (I managed to trace that to a poorly configured log rotation setup) but not one of those logs could help me – seriously why is it Samba keep so many logs expect the one your interested in!

Unfortunately I wasn’t able to answer the question about where the missing files went, but this isn’t the first time I’ve been asked this question so, next time – and, as any good system admin knows, there is always a next – I want to be able to know what happened.

In this post I will talk you through configuring Samba 3.6.3 to keep a full user audit trail, recording all changes made to the file system – including deletions.

In my own research I was quite impressed that Samba can actually do this already, its just not on by default. The trick is to use a Stackable VFS Module called full_audit. The system I was setting this all up on was a Ubuntu 12.04.5 LTS (precise) and already had full_audit installed so I didn’t need to worry to much about that. To check if its installed on your system you can look for the file /usr/lib/samba/vfs/ if its there eveything is installed and working – if it’s not, let me know in the comments bellow because I haven’t found a system which was missing it yet.

Setting up the share

I’m only interested in creating an audit trail for one of the server shares so these setting can be put assigned to the one share configuration. So when all is done the final configuration in /etc/samba/smb.conf will look like this – don’t worry to much about it, it works and I’ll go through it line by line.

When you copy this into your smb.conf file make sure not to copy the current share configuration part too

The normal configuration section you should know already, so let look at the new parts:

vfs objects – Tell Samba to load the new module

full_audit:prefix – This defines how your new log will look and fully supports using Samba variables. The format I’ve chosen is:
%U = Samba username
%I = Client IP Address
%m = Client Hostname
%S = Current Share name – not technically needed since I’m doing this for a single share but probably worth keeping encase the configuration is expanded later
For now ignore nasaudit at the start, but I’ll come on to it again later.

full_audit:success – What actions will user actions to log:
mkdir = Upload/Create new directory
pwrite = Upload/Create new file
rename = Rename a file
rmdir = Delete a directory
unlink = Delete a file

full_audit:failure – The same as full_audit:success but when the action failed

full_audit:facility – Which syslog facility to log to. We can use this later to direct messages out of syslog and into a more useful file

full_audit:priority – The priority to set log messages as.

So there you have it. Next time you restart Samba it will log a whole lot more about what a user is actually doing on your file system, but currently logs are going in /var/log/syslog so in the next step we’ll have to get them out of there into a file of their own.

Redirect the logged output

I use the rsyslog daemon rather then syslog, but the process bellow should work for ether one.

We told Samba to output logs to facility ‘local5’ so we can tell rsyslog to look for that, but rather than just take everything that gets sent to local5 we can use a filter and on messages that contain nasaudit – see told you it I’d come back to it.

Now we know what we’re planning to do lets put it all together. Just add the following line, ether to your /etc/rsyslog.conf file or better still create a new file in the /etc/rsyslog.d/ directory.

Rotating logs

The final thing we need to do is add this new logfile into the /etc/logrotate.d/samba configuration file. This way we get a nice clean audit folder, since these audit logs could be quite long on a busy server trying to search though a single file would grow old – fast

Open up your /etc/logrotate.d/samba in your favourite editor and copy in the block bellow:

This will rotate the logs every day and keeps 90 of them. Deciding how much to keep and how far back you will need to go is going to be a personal thing. In my case I’ve gone with three months to start with so and it’s simple enough to tail that back.

Raspberry Pi Bitcoin Core 0.10.2 Installation
14 Jun

Raspberry Pi Bitcoin Core 0.10.2 Installation

This weekends project is setting up a Raspberry Pi as an online Bitcoin wallet.

As you might the first step has been installing Bitcoin Core. There is no binary Bitcoin available for the Raspberry Pi’s ARM process so I had to build it from source. Less I Forget here is my step-by-step guide:


  • Raspberry Pi 2
  • A 2A power supply
  • External HD
  • Raspbian OS Image Downloaded from here
  • The blockchain – Optional but could save days of waiting

Installing a Clean OS

First thing to do now we have a Raspbian install image is copy it to a new microSD card.

Being a Linux user I just copy the image from the command line using dd:

dd is a Unix command so if your MacOSX user the same command will work for you as well. It takes a few minutes but gets the job done. For Windows users a program like Win32DiskImager can do the install for you – full instructions can be found here.

Raspi-Config / Updating

As normal with a new installation raspi-config will run during the first boot. What we need to do here is expand the file system to take up the whole sdcard – no point in empty space just sitting around looking prity.

Once that’s done enable the SSH server. The Pi will reboot after your exit raspi-config so just let it do its thing.

Once the Pi is back up and running you can now keep working working with an attached keyboard a mouse of fire up and SSH connection from another machine and work from there, the choice is yours.

If you do choose the SSH option make sure you start a screen session, since the commands we’re about to run could take a few hours on the Raspberry.

If you need a pointers, the quickest way to get the Raspberry’s IP address is running ifconfig from the command line. The default username is pi and – if you didn’t already change it – the password will be raspberry, but I would highly recommend changing it as your first step passwd will do the job.

Now that we have a running Raspberry Pi and we’ve logged into a terminal – ether thru the keyboard and monitor or over SSH – we’re going to quickly run an OS update:

Installing Bitcoin

Getting the dependencies

We’re going to have to build Bitcoin Core from the source code, and for that we need the build tools and dependent libraries installed:

We also need to install the BerkeleyDB 4.8, since its not available from apt-get we’ll need to build it from source as well. This will take a while so probably best grab a cup of coffee or something, but if your using a Raspberry Pi2 you can replace the make command with make -j4 to spread the load over the extra cores.

Getting the source

Now that the system is ready we can finally start on Bitcoin. First get the source code from the GitHub repository:

Building it

Next we’ll configure it for our system and get the build started. Again this will take ages, but you can speed it up on the Raspberry Pi2 by using the make -j4 command instead of just make – for reference I just used the make option and it was done in about 3 – 4 hours.

Up & running

… and we’re back. We now have Bitcoin Core 0.10.2 installed on our Raspberry. Before we run it for the first time we need to make sure we can download the blockchain. At present the blockchain is over 35Gb. Since we can’t feasible store it on our microSD card we need to put it on an external hard drive.

If you’ve never plug an external drive into a Raspberry Pi before, its worth pointing out the Pi doesn’t have enought power to support the drive directly. You must ether get a drive back with it own power or plug the drive into a powered usb hub.

Once your drive is ready you have a few options for telling Bitcoin Core where to put the blockchain. Ether mount the external drive to /home/pi/.bitcoin or create a symlink there. The final option is to pass the the new location to bitcoin over the command line bitcoin-qt -datadir=/path/to/harddisk/

One last thing before we fire up the Core. If you already have a copy of the blockchain copy this to the Raspberry Pi, it will save hours or even days of waiting. However, if like me you don’t you may run into the same problems I have.

When I started running bitcoin-qt it will crash. After Googling around the error message relates to a lack of memory. The Raspberry Pi2 has 1GB or ram but its appears that isn’t always enough. Since adding more RAM isn’t a practical option I’ve resorted to running this script:

This handy little one-liner will restart bitcoin-qt every time it closes – in my case crashes – and the download will resume where it left off.

I’m not sure if this problem is histochemic of the Raspberry Pi or just while the blockchain is downloading but once my downloads completed I’ll get a better idea and can give some more feedback.

Fedora/Yum update notification in OpenBox
06 Feb

Fedora/Yum update notification in OpenBox

OpenBox is a minimalist windows manager for Linux, it’s also my manager of choice. Due to its minimal memory footprint its faster than Gnome or KDE, but because its minimal a lot of what you may have come to know and move is no enabled by default.

I will cover more about OpenBox and its configuration in future posts, but this evening I decided to check for any updates to Fedora 21 and to my surprise I found over 200 updates waiting on me. I know, I am really bad at checking for updates but so are you so don’t judge!

When you log into KDE or Gnome many other services and background programs are run, one of which checks for system updates and alerts you. There is no such thing running by default when your first run OpenBox so I created a Bash script that runs in cron. It uses the notify-send command to pop-up alerts when updates are available.

Create a new file in /usr/local/bin/yum-watch and copy in:

Now make sure the file is executable with sudo chmod 700 /usr/local/bin/yum-watch. Now just add your new command to cron or run it at startup and you’ll start getting notifications if and when new updates are available.

Overclocking RaspberryPi
17 Dec

Overclocking RaspberryPi

By default the processor in the Raspberry Pi runs at 700MHz, but it can be overclocked without voiding your warranty. Basically a processor is designed to do one job at time, be it retrieving something from RAM or adding to numbers together, its limited to one task. But when we’re using them the idea of one thing at a time is hard to get our head around since it appears to be doing so much more. That’s because a processor can do that one task really, really, really, fast. The clock speed, 700MHz, give us an idea of how many tasks it can do per second; the higher the speed the better performance you get.

Overclocking simply means increasing the clock speed past its defaults. The problem there is if you overclock to much the processor becomes unstable and can lead to crashes or even burn its self out.

My Raspberry Pi is running Raspbian so to overclock it simple type sudo raspi-config

Go down to item 7 Overclock and press ENTER, press ENTER a second time to confirm the warning message.
raspi-config select frequency

raspi-config has five levels of over clocking: 700MHz (no overclocking), 800MHz (modest), 900MHz (medium), 950MHz (high) and 1000MHz (turbo). All of which are supported by the Raspberry Pi foundation and will not void your warranty, over clocking to anything other than what’s on this list or overvolting the Raspberry Pi will void the warranty.

Select the level of overclocking you want from the list, as bellow, and click on <Ok> to confirm your selection.
raspi-config select frequency

After that your Raspberry Pi will need to reboot for the new settings to take effect. After a reboot you can test your settings by looking in /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq

If for any reason your Raspberry Pi fails to boot after you’ve overclocked it hold down the shift key at boot time to temporarily disable overclocking then just go back into sudo raspi-config and select a lower speed.

Install Oracle Java JDK or JRE 8u11
18 Jul

Install Oracle Java JDK or JRE 8u11

I do not format my desktop PC very often, I reinstall my laptop three or four times a month but not my primary machine. With almost every clean installation I have to lookup how to install Oracle’s Java instead of using the pre installed version OpenJDK.

Since I search for it so often I thought it was well past time I wrote a guide of my own.

What’s New in JDK 8

Java 8 is a major feature release on version 7. The updates are too many to go into great detail here, but Oracle have a full feature change log on their own site


This guide will tell you how to install Sun/Oracle Java JDK and/or JRE 8u11 on Fedora 20, 19, 18, 17, 16, 15, 14, 13 and 12 – I haven’t tested on all these version of Fedora, only 20 & 19, but Fedora haven’t change the process so much that this wouldn’t work on older versions. If you do find any problems, please let me know in the comments section and I will get the guide updated.

Install Sun/Oracle Java JDK/JRE 8u11

Download 32bit of 64bit RPM packages

Download the RPM files from Oracle’s download page. Depending on your system, 32 or 64bit, download:
* 32-bit JDK download jdk-8u11-linux-i586.rpm
* 64-bit JDK download jdk-8u11-linux-x64.rpm
* 32-bit JRE download jre-8u11-linux-i586.rpm
* 64-bit JRE download jre-8u11-linux-x64.rpm

Install the RPM packages

Next just install the RPM package you’ve just downloaded using one of these commands

Set the newly installed Java as the system default

Now that your Java 8u11 is installed you need to tell Fedora to use it by default. The alternatives simply created links from the system default paths to the new java installation directory

Install Browser plugin for Firefox

Most people do not need to do this, I never do. If you dont know you need java inside your browser skip this step – you can always come back to it later if you find you need to run java from within in Firefox.

Set up Java Development Kit

You only need this if you installed the JDK. These two commands, javac and jar, are just used to complie java code and package the result files for distribution.

If you need to run multiple versions set 8u11 to the default

In the steps above you have replace the already installed version of Java with 8u11, but you havent removed it. If in future you install 8u12, but still want 8u11 to be your default you can specifiy the version of java to pass to alternatives instead of using latest.

JRE Users

JDK Users

Make sure its all worked

Just a quick check to see its all work as you expect

Post Install

You now have Java installed, the last thing to you need to do is make sure you have the JAVA_HOME environment variable set on your system.

You can do this per user by adding the above to $HOME/.bash_profile or make it a system wide setting by adding it to /etc/profile

Switching JRE

Now you have installed Oracle Java, and used alternatives to set it as the system default, you may come across occasions when you need to switch the system back to OpenJDK. You can use the alternatives command with the –config argument to set things up the way you want.


javaws (32-bit) (64-bit)


14 Jul

Revert to a previous Git commit


I make heavy use of git for all my software development, when asked what the point is for a one man development team to something as powerful as git I always reply “universal undo”.

With a recent update to the site i finally got the chance to use it the way I’d always expected to, and it worked exactly as expected but the correct process was harder to find than expected. So here is how I was able to revert my master git branch after committing some bad code:

Reverting Working Copy to Most Recent Commit

To revert all uncommitted changes back to the previous commit: git reset --hard HEAD where HEAD is the last commit in your current branch

Reverting Working Copy to an Older Commit

This is a some what controversial step, but it was what I needed and the only thing I could find that would work. The better option is to avoid a hard reset if other people have copies of the old commits, because using a hard reset like this will force them to have to resynchronize their work with the newly reset branch. This isn’t a problem for me, but it is worth mentioning encase it would be for you.

To revert back to an already committed change:

05 May

Install SSH Key In A Remote Linux Server

I’ve been setting up a new server and as always the first things to do is forbid root login using a password and install my SSH keys. Once again I had to Google for how to do this, so I thought I would write about it instead.

After creating a new SSH key, if you don’t already have one, you can install it into the target computer using the ssh-copy-id command to install you certificate directly onto the machine.

There are many ways to use the ssh-copy-id command:

  1. Create the SSH keys:

  1. (A) Install the public key:

  1. (A) I If you do not have ssh-copy-id installed on your PC this will also work:

02 Nov

DNS Cache TTL – Windows

Shorten the built in Windows DNS cache time

To force Windows to keep positive entries in DNS Cache for only 4 hours instead of the default 24 hours we need to apply the following change to the registry:

02 Nov

Block Negative DNS Entries – Windows

Windows contains a client-side Domain Name System (DNS) cache. The client-side DNS caching feature may cache results when no valid IP address was found. This article describes how to disable DNS caching for these Negative Entries.

To force Windows not to cache negative entries we need to add a new DWORD to the Windows Registry

01 Jun

Getting Saitek X52 Joystick Working Within Linux

Now that Steam is available for Linux (How to install article coming soon) I have once again made the switch to 100% Linux. How that I have Steam installed I wanted to start playing Egosoft’s X3 series again, but for best performance this really needs a joystick. This is how I went about installing and using my Saitek X52 joystick in Fedora 18.

The problem is as of Fedora 17 the joydev kernel module was removed by default. The result is when a new joystick is plugged in the require paths in /dev/input/jsX are not being created, so your software and games can not find the device. So we need to reinstall the joydev module.

After installing the kernel joydev module the joystick and all its buttons are detected by the latest kernel (which as of writing is)

The Install Instructions for a fresh install

  1. Even though joydev was stripped from the default kernel it has been bundled into an easy to install package available in the yum repsitory

2. Now the kernel software is installed we need to load it. You can ether take a moment and reboot your PC, the modules will get loaded at boot time, or you can load them your self with modprobe

  1. After the new modules have been loaded you can plug your joystick in and you should see the new paths being created under /dev/input it will be something like /dev/input/js0. You can not test to make sure your joystick is being detected correctly using ‘jstest’

Installing Qjoypad Optional, mapping buttons to the keyboard

The Saitek X52 has over 30 buttons on it so the easiest way to set these up would be mapping them to keyboard shortcuts. Luckly, with a little Googling, I found a fantastic tool for this. Qjoypad is a Qt based program that will just sit in your tray and map any button presses to the associated keyboard shortcut.

There are no binary packages, that I could find, but installing from source is fairly painless. There are alternatives out there, but I haven’t spent any time with them. I found Qjoypad first, and for my purposes, it was perfect. If you find something you think is better please let me know in the comments!

  1. Install Qt dependancy packages

  1. Download the latest version of Qjoypad, as of writing that was 4.1.0
  2. Extract downloaded file

  1. Change directory into main source folder

  1. The distributed config file makes a check for qmake, unfortunitly this will fail in Fedora as the qt-devel package installed qmake as qmake-qt4 so we can just comment out the check in line 14-17

  1. Now run config to generate the Makefile

  1. Edit the new Makefile and append -lX11 to the end of line 19. I’m not ‘up-to-scratch’ with Makefiles and compiling, so I’m not able to give a good reason for this, I just now without it ‘make’ will fail to compile. If someone can explain it better than I leave a comment and I’ll happily update the article

  1. Now as root run the install

  1. Run QJoypad

Qjoypad will run in your system tray and can be opened by double clicking. From there you can setup your profiles and key bindings. There is support for multiple profiles as well so you are able to set different bindings for each of your games and load them as required.

I hope this has been of help to you, I know I’ll be refering to it after my next install. Please leave me a comment bellow if this was of help, or you’ve found any problems.

As always, if you have been, thanks for reading

Rooting the Google Nexus7, in Linux
20 Mar

Rooting the Google Nexus7, in Linux

In a previous post I talked about installing CyanogenMod 7.1 Alpha 3 on my HP TouchPad, but since Santa was very nice to me this year I now have a Nexu7, and of course I want to root it. Most of the toolkits and instructions I found talked about doing this thru Windows, but I’m a Linux guy and don’t want to install Windows for what will take less than an hour. So further Googling came up with a way of doing it thru Linux.


Like every site before me, be warned. Follow this guide at your own risk. Rooting, unlocking and installing new ROMs does invalidate your warranty and risk causing damage to your data and/or device. While nothing bad has happened to me followed these instructions, you can’t discount the idea entirely. So BACK UP YOUR DATA – If you don’t Murphy’s Law says you will need it

The Toolkit

There are alot of ways to ‘manually’ unlock your device, but all the ones I was able to find involved downloading the Android SDK. This is a good way to do things if you ether know what your doing, or want a better understanding of the steps involved. However I wanted it done quick, and at the time I was on my netbook and seen no need to install the entire SDK. So I chose to use a toolkit.

The next problem was finding one. The vast majority of kits run under Windows, as previously stated I’m a penguin at heart and needed to find a Linux kit. tatelucas, member of the XDA-Developers forum – if you’ve never checked it out you really should – was there with the solution: Universal Nexus Linux Toolkit, formerly named galaxy-nexus-linux-toolkit. At the time of writing his toolkit supports the

  • Nexus 4 mako
  • Nexus 10 manta
  • Nexus 7 (WiFi) grouper
  • Galaxy Nexus (GSM) maguro
  • Galaxy Nexus (Verizon) toro
  • Galaxy Nexus (Sprint) toroplus
  • Nexus S (worldwide version, i9020t and i9023) crespo
  • Nexus S (850MHz version, i9020a) crespo
  • Nexus S (Korea version, m200) crespo
  • Nexus S 4G (d720) crespo4g

however I have only tested it on the device I have, the Nexus 7 grouper. This toolkit allows you to unlock and re-lock the bootloader, get root access, install ClockworkMod recovery both touch or standard version and, if you feel the need, reinstall the Google stock rom.

Requirements So what do you need?

  • Android Debugging Enabled
  • Universal Nexus Linux Toolkit – The best method for this is using git, but you could also browse the repository down manually download the files, I will be using git

Downloading from git Just in-case you don’t know how

Getting Root

Now that we have a copy of the files, in my case stored in “~/RootNexus7/galaxy-nexus-linux-toolkit”, change to the stable source, the folder called “stable”, and we can start the install.

From this point on the installation is straight forward. Tatelucas has made the interface really easy to use and the on-screen instructions detail each option and tell you want you need to be doing on the table.

Now you have root

If everthing worked as expected you should now have root access to your Nexus. The first thing I would recommend you do now is install a proper/full backup package. My app of choice is Titanium Backup ★ root. After that… do a little Googling, the platform is now your oyster – enjoy

If you like this toolkit, why not buy the developer a coffee?

Donate to tatelucas with PayPal

Setup your own Firefox Sync Server
15 Mar

Setup your own Firefox Sync Server

As most people know I hate using someone else’s service when I can host my own and since I’ve started using Firefox for Android that’s no exception.

Firefox allows you to sync your preferences, bookmarks and add-on settings between devices using the Firefox Sync Service, but they default servers are hosted by Mozilla. This isn’t a problem for me as they encrypt all data in the client before its transmitted to their servers, and if you don’t trust the client then there are bigger problems. Still I like to ‘roll-my-own’ when ever I can and Mozilla have made running you own sync server very easy.

The instructions bellow are based on my current install. Which is Ubuntu 12.04.1 LTS, MySQL and Apache2. These steps worked with out any problems for me – please let me know in the comments how you get on and if you find any problems or have to take any additional steps I missed out.

As yet Mozilla don’t release any binary packages for their server, so to install one what I’ll be doing it checking out the latest release from their repository and building it in-place

Prerequisites These are the things you’ll need

Like most software, the server is made up of several components that all work together to form the final application. In-order for them to work you will need to make sure your system has these installed, or install them now:

To install these on my Ubuntu machine I just make the this request of Apt-get:

The Build Use the source

Now that your machine is ready you need to get a copy of the latest source code from

No we have the source we can use the build command to make an Python environment isolated from the rest of the system. It’s into this environment all the required dependences are installed :

In a unique step for I even got make to ran the testsuite on the compiled source:

In the end this worked out to my advantage because it found a missing dependency. Using the pip command I installed pysqlite into the new python environment:

Running test again produced no error so it’s safe to move onto the configuration

The Configuration Make it work

To configure the server you only need to edit the ini-like setup file “./etc/sync.conf“. The is well commented and you will probably be able to make seance of it. In the most part the defaults worked fine for me, but you do have to change a few things.

The first is the fallback_node URL. This is the client visible URL of your service and make sure node-assignment and user registration works correctly. The default value has port 5000 specified in the URL. This is in-case you are running in standalone server mode, I am not as I will be putting Apache in front of the server so I just took it out:

Out-the-box the server will use sqlite files for the user and storage database. You’ll see in the configuration file these are being stored in “/tmp” this is obliviously an terrible idea for a production server, so next well move them to a more appropriate place:

Apache Running behind a Web Server

At this point the server already has a server built in which I’ve not talked about, partly this is because while it is good testing it should not be used in a production environment but mostly its because I never had any cause to run it.

For production server you will need a web server which is compatible with WSGI protocal. These include, but are probably not limited to:

  • Apache – Combined with mod_wsgi
  • NGinx – With Gunicorn or uWSGI
  • lighttpd – With flup, using the fcgi or scgi protocol

I will be talking about the first option as my server was already configured for it.

Create a new Apache configuration file for your server, bellow is an example of the configuration I used:

That should be you done. Just reload your Apache server to activate the new host and start playing:

Security & User Registration It’s not a dirty word you know!

After installation and Apache setup your ready to rock and or roll! However in the default configuration the server support new user registration using the Firefox built in interface. Now unless you are going to make your server public to the world it’s a good idea to disable this after you have setup your own Firefox instance:

Getting Logitech Custom Mouse Buttons Working Within Linux
13 Mar

Getting Logitech Custom Mouse Buttons Working Within Linux

Having lived in a Windows environment for the past couple of years I’ve gotten somewhat used to my routines and short cuts, most of which are missing or changed now that I’m 95% Ubuntu. The most notable absentee are all the extra buttons on my Logitech MX Revolution mouse, which I have mapped to a vast array or custom key stroked. So, lest I forget, this is how I have got these custom buttons working correctly.

All these buttons are detected by the latest kernel (which as of writing is)

This is great news because all we need to do now is map each button against the desired application/keystroke.

My system of choice is Ubuntu 10.10 as of writing, this has since changed to Fedora so all the command line and install command listed are correct for this distributions as of writing. If you find other commands work on other distributions leave a not in the command and I will be sure to update the main article.

The Install Instructions for a fresh install

  1. We should install xbindkeys. This will re-map mouse and keyboard inputs so the install is…

The goal is to configure the mouse buttons to send key combinations to activate o

ther desktop or application functionalities. Technically all xbindkeys is doing is executing an application in response to a keystroke or mouse button.

  1. So in-order to map a mouse button to a keystroke we have to install an application called xte, which in Ubuntu comes as part of the xautomation package which can be installed like this

  1. Now we need to create a configuration file for xbindkey, which can be done like this…

  1. We need to edit this file in a text editor. I use nano, but vim, kate or gedit are just as good but you can of course use what ever editor you would prefer to…

The xbindkeys configuration file has a very simple format…

  1. So we need to add our button-to-key configurations, but first we need to know what ‘events’ the mouse buttons are triggering before we can remap them. For this we can use xev, this program is a key and mouse event sniffer. It runs by opening a small window. You can now start pressing keyboard or mouse buttons over the window and see if they are detected. For example the forward button on my Logitech Revolution MX looks something like this:

Bellow I’ve included a table for the Logitech MX mouse, these will probably be if you have a newer, or older mouse

Mouse Button Event Code xbindkeys Code
Thumb Scroll Up 13 b:13
Thumb Scroll Click 17 b:17
Thumb Scroll Down 15 b:15
Thumb Button Up 9 b:9
Thumb Button Down 8 b:8
Left Button 1 b:1
Right Button 2 b:2
Scroll Up 4 b:4
Scroll Down 5 b:5
  1. Now that we have a list of all our button codes we can move on to actually writing the configuration file. For example I have this to map the Thumb Button Up and Thumb Button Down buttons to switching workspace in my Gnome shell, these keycombinations are specific to my setup so you will need to chnage them. What I’m doing here is pressing the ‘Windows’ key ‘Left Control’ then ether ‘Down’ or ‘Up’ then releasing the other two keys…

The Rapup Now we make it all work

Thats all there is. Once you have setup your /.xbindkeysrc confirguration file, you just need to configure xbindkeys to run automatically on system startup. This is going to be different depending on your windows manager, but here are the steps for KDE and Gnome

  1. There’s a tool in GNOME 3 which allows you to add, modify and remove autostart entries and you can run it by executing from a terminal or from the ALT+F2 dialog. Just run gnome-session-properties
  2. Click on “Add”
  3. Write ‘Xbindkeys’ in the Name and ‘/usr/bin/xbindkeys’ as the Command and press OK.
  4. Done!
  1. Open System Settings.
  2. Go to Advanced tab -> Autostart.
  3. Click on “Add Program…”.
  4. Write ‘/usr/bin/xbindkeys’ and press OK. A new dialog pops up. Press OK again.
  5. Done!
Installing CyanogenMod 7.1 Alpha 3 on my HP TouchPad
24 Feb

Installing CyanogenMod 7.1 Alpha 3 on my HP TouchPad

I have just finished installing CyanogenMod 7.1 Alpha 3 on my HP TouchPad. Its gorgeous. I cant say I ever become a fan of WebOS, unlike some I’ve talked to it never grew on me and the rare times when I did want to make use of it the App Market was far too over priced and in my experience limited, but now with Android the device ‘sings’

The install was a breeze in the end, all the same here are the steps I went threw. I never needed to do any disaster recovery so I don’t list any. How ever I would highly recommend anyone interested in doing this to read the FAQ at before going any further it contains all the disclaimers and alpha-software warnings you would expect as well as an in-depth list of disaster recovery options.

The Install Instructions for a fresh install

  1. Prepare your PC for the installation by downloading the Palm SDK from the HP website. The site has full easy to follow instructions for Linux, Windows and OS X users so replicating them her seems redundant. Once you have installed the the SDK you can continue with the steps listed bellow.
  2. You now need to download the required software. At the end of it you will end up with the four files:
    • – RootzWiki Forumi
    • – RootzWiki Forumi
    • – RootzWiki Forumi
    • – Moboot Projecti
  3. If you wish to have access to the extra Google apps, like Gmail, YouTube or the Android Market you will have to download the latest gApps installer from the CyanogenMod wiki site
  4. Unzip the file. On Linux systems you can leave it where you downloaded it too, but in Windows at least it will make like a little
    easier if you move the unzipped file to the same directory you installed the Palm Novacom SDK to. On my VirtualBox machine it is C:\Program Files (x86)\Palm, Inc but I’m running a 64bit system, in 32bit the directory will probably be C:\Program Files\Palm, Inc
  5. Now connect your TouchPad using its USB cable to your PC. The TouchPad will notifiy you that its detected a new USB connection. Tap the symbol to mount the tables SD card on your computer.
  6. Open your file manager and on the root level of the SD card create a new folder called cminstall. Into this new folder copy the zip files you
    downloaded before, do not unzip them and don’t copy file, just leave this file on the PC for now. Once your done the contents
    of your new “cminstall” folder should be:

    • – *You only need this if you’re planning to install the extra Google Apps
      7.You now need to reboot the TouchPad. Make sure you eject the TouchPads SD card correctly from your PC, some systems delay writes to external USB devices to speed things up.
      Once the TouchPad has been removed follow these steps to reboot it, while the USB cable is still connected:
    • Press the Home Button
    • Bring up the Applications List
    • Select the Settings Tab
    • Open Device Info
    • Press the red Reset Options button at the bottom of the screen
    • Press the grey Restart button at the top of the screen
  7. As the TouchPad reboots the screen will turn off, as soon as this happens press and hold the Volume-Up button. Keep holding it until a USB icon fills the display. After a few second your computer will recognize the TouchPad.
    • Under Linux, open a terminal and change directory to the where you unzipped the file
    • Under Windows, open a command prompt and change directory to where you installed the Palm SDK:
    • Open the start Menu
    • Type cmd (no quotes) hit enter
    • A black and white terminal window should have opened
    • To change directory, type cd c:\PATH for me the path is C:\Program Files (x86)\Palm, Inc so I typed: cd C:\Program Files (x86)\Palm, Inc


  8. On both systems enter this command novacom boot mem:// < ACMEInstaller
  9. Make a cup of tea. That’s really all there is to the install. It will take a few minutes but once its done the TouchPad will reboot into Android
Non-Root Ubuntu Shutdown
24 Feb

Non-Root Ubuntu Shutdown

It may at first seem rather daft that you must become root before you can shutdown you PC, but it does make sense. Linux is designed as a multi-user system, just think of any web site you’ve ever visited. Many different people can be accessing the same site at the same time and that’s to say nothing for the other people hosting their site on the same machine. Could you imagine the chaos that would result if any one of those users were able to turn that machine off at will? You may still be thinking “ye, but they could pull the power” but, they couldn’t, the users I am referring to have no physical access to the machines in question so securing the shutdown commands in this way is still highly effective.

In my research I have come across a couple of different methods to achieving the goal of non-root shutdown. The /etc/shutdown.allow file is a common option, however it fails the ‘usability’ test for me as it requires a number of other steps and relies on keyboard shortcuts to be correctly configured and not intercepted by other process. Because of that I have decided to go with the sudo method as my recommended choice.

The SUDO Method

In-order for user of the ‘shutdown’ group to turn off the machine we must create the group ‘shutdown’. So run this command, prefixing it with sudo to make sure it is run as root

Next we need to start adding people to our new shutdown group. This command will do the job, just replace username with your username.


Anyone you add to this group will be able to shutdown your computer, even when they’re not sitting at it so be selective in your choices. The next thing we need to do is give the shutdown group permission to invoke the command for shutting down or rebooting. In Linux these command are /sbin/shutdown, /sbin/reboot or /sbin/halt so now run the visudo command and add the following lines.

That’s you done. Now anyone in the shutdown group can now run sudo shutdown as if they were root and shutdown the computer.

The Next Step?

At this point you may have notice that users still have to prefix the shutdown command with sudo. I personally like this as it reduced the risk of typo etc.. but I know for some (or most) its still a pain, so we can remove it.

What we need to do is create a script in /usr/local/bin/shutdown which prepends the sudo command for us.

Now just make the script executable and, for a little extra protection, change its ownership to out new shutdown group