An easy way to enable VNC in Ubuntu 14.04

i’ve struggled today for a few hours to get XDMCP connections running on my new tv server. in the end i posted on a few forums and gave up. a bit frustrating!

but i still didn’t want to leave my seat without having any ability to log into my server without gui, so i opted for a simple vnc server solution:

  1. you need to have the gnome-session-flashback package installed through apt-get
  2. you need to log into at least one session that is a gnome (fallback) one.
  3. go to applications > system tools > preferences > desktop sharing
and that solves the problem. you must have at least one desktop session running, logged into Gnome-flashback and this user must have the connection allowed.

Removing unused Kernel files via command line

regular kernel updates are great, but having 3 years of kernel updates on one hard disk is not. chances are you are never going to use any of the 10 or 20 that you installed last year. if everything continues to work fine, why would you?

you can obviously use a package manager, such as synaptic, to uninstall unwanted programmes. quite often you might find a few other programmes that you didn’t know you had still and want to get rid of. but it’s generally easier to just use the command line to remove things quickly.
use this command:

dpkg -l ‘linux-*’ | sed ‘/^ii/!d;/'”$(uname -r | sed “s/(.*)-([^0-9]+)/1/”)”‘/d;s/^[^ ]* [^ ]* ([^ ]*).*/1/;/[0-9]/!d’ | xargs sudo apt-get -y purge 

i use this command in ubuntu and i’m pretty sure it will work in derived versions, but results may vary!

Exporting Sound with XDMCP

Some of you might be connecting to your remote linux box using XDMCP. While that would export the display,what would one do if one wanted to play a song on the remote box but hear it on the present system? well that can be easily done using the arts server on the remote machine setup the arts daemon by typing

artsd -n -u -p 5001

once the server is started change to the X display of the remote machine and type in

export ARTS_SERVER=ipofcurrentsystem:5001

and then

xmms &

Voila you will have a complete remote desktop including sound just like in windows xp.

Script to disable & enable touchpads

I constantly touch the touchpad when I type. I also normally use an external mouse when I’m on my laptop. I seldom really need it, but I will sometimes want to switch it on (or off).

First you need to find the name of your touchpad in the xinput list:

$ xinput list

⎡ Virtual core pointer                     id=2 [master pointer  (3)]

⎜   ↳ Virtual core XTEST pointer               id=4 [slave  pointer  (2)]

⎜   ↳ Razer Razer Imperator                   id=10 [slave  pointer  (2)]

⎜   ↳ Razer Razer Imperator                   id=11 [slave  pointer  (2)]

⎜   ↳ PS/2 Mouse                               id=13 [slave  pointer  (2)]

⎜   ↳ AlpsPS/2 ALPS GlidePoint                 id=14 [slave  pointer  (2)]

⎣ Virtual core keyboard                   id=3 [master keyboard (2)]

    ↳ Virtual core XTEST keyboard             id=5 [slave  keyboard (3)]

    ↳ Sony Vaio Keys                           id=6 [slave  keyboard (3)]

    ↳ Video Bus                               id=7 [slave  keyboard (3)]

    ↳ Power Button                             id=8 [slave  keyboard (3)]

    ↳ USB 2.0 Camera                           id=9 [slave  keyboard (3)]

    ↳ AT Translated Set 2 keyboard             id=12 [slave  keyboard (3)]

So in my case the touchpad is most likely: PS/2 Mouse on id 13.

You can easily identify if the device is “on” (enabled):

$ xinput list-props “PS/2 Mouse” 

Device ‘PS/2 Mouse’:

Device Enabled (144): 1

Coordinate Transformation Matrix (146): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000

Device Accel Profile (267): 0

Device Accel Constant Deceleration (268): 1.000000

Device Accel Adaptive Deceleration (269): 1.000000

Device Accel Velocity Scaling (270): 10.000000

Evdev Axis Inversion (271): 0, 0

Evdev Axes Swap (273): 0

Axis Labels (274): “Rel X” (154), “Rel Y” (155)

Button Labels (275): “Button Left” (147), “Button Middle” (148), “Button Right” (149), “Button Wheel Up” (150), “Button Wheel Down” (151)

Evdev Middle Button Emulation (276): 0

Evdev Middle Button Timeout (277): 50

Evdev Wheel Emulation (278): 0

Evdev Wheel Emulation Axes (279): 0, 0, 4, 5

Evdev Wheel Emulation Inertia (280): 10

Evdev Wheel Emulation Timeout (281): 200

Evdev Wheel Emulation Button (282): 4

Evdev Drag Lock Buttons (283): 0

 Now create yourself a little file (eg: “touchpad”):

# toggle synaptic touchpad on/off

SYNSTATE=$(xinput list-props “PS/2 Mouse” | grep Enabled | grep -Eo ‘.$’)

if [ $SYNSTATE = 0 ]; then xinput set-int-prop “PS/2 Mouse” “Device Enabled” 8 1

else xinput set-int-prop “PS/2 Mouse” “Device Enabled” 8 0; fi

dengar@dengar-vaio:/usr/bin$ $ xinput list-props “PS/2 Mouse” 

This should sort you out. Don’t forget to  change the name of your actual device, remember mine is “PS/2 Mouse”

Next you need to make the file executable:

sudo chmod +x touchpad

Now, to have that file available from the command line, simply copy it to /usr/bin.

Create a home VPN and allow computers to connect with each other

Like most organisations, my workplace has quite strict security policies. For some reason, I wasn’t allowed and able to connect to the data centre through the Cisco VPN that had been set-up by our company. I had to had a static URL at home that needed to be allowed, but I wouldn’t consider changing my provider purely for that benefit.

There are plenty of options to ‘break’ that security restriction, like having a Terminal Server within your corporate network that you could log onto. The slow and clunkiness of that solution turned me off. In addition, I would have to get helpdesk to install all sorts of programmes and, since I’m a Linux man, I would have to compromise on every which way.

The easiest solution, I thought, was, since I can’t VPN onto the network from home, to VPN to my home network from work!

I already have a server for various tools that keeps on running most days and nights, so why not also use it as a VPN server.

Installing and configuring the necessary software is easy and takes just minutes.
First you will need to install the PPTP daemon:

$ sudo apt-get install pptpd

In Ubuntu, the configuration file for the pptp-daemon is: /etc/pptpd.conf and we will need to modify it so there is a separate IP defined for a) the server (which can be the one the server is getting from your router) and b) the client(s). If you have more than one client you will obviously have to make sure you have a range of IPs available for the clients.

In my case, since the networks should be quite separate at home and through VPN, I decided to use a different IP range. My router assigns IPs in the range 192.168.1.XXX, so I will use the range 192.168.0.XXX through my VPN server. You will need to update the last lines of your pptpd.conf like this:

localip 192.168.0.1
remoteip 192.168.0.2-10

This assigns the IP ~.1 to the VPN server (a separate interface) and allows the numbers ~.2 to ~.10 to be assigned to clients.

Next step: create VPN users and their passwords. This is stored in the /etc/ppp/chap-secrets file. Here is an example:

# Secrets for authentication using CHAP
# client server secret IP addresses
CLIENTLOGIN pptpd CLIENTPASSWORD *

You could obviously restrict the IP addresses the client can connect, but a very long password should also be quite secure.
In theory that’s all you need to connect, but you might want to allow clients to use the server’s internet connection and allow it to connect to other IPs within your local network. For this we will need to use NAT and IP forwarding. You can enable this via adding this line to your /etc/rc.local (before exit):

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

and in /etc/sysctl.conf uncomment the line:

net.ipv4.ip_forward=1

Now you can restart the daemon:

$ sudo /etc/init.d/pptpd restart

If your computer doesn’t use the public IP address, eg. you are behind a modem – router or a firewall, you will need to forward the port 1723 to your server. And to avoid trouble with dynamic IP addresses you get from your ISP, you should use a dynamic DNS service. This will update your current IP to the DNS lookup tables and you get an easy URL name to remember. I think I use DynDNS.org.

Finally, you are on the client, but you can’t see any other computers within the VPN or the local network of the server. This is because the routing is not set correctly on your client computer. You will want to “search” this VPN IP range through the VPN server, not your normal internet connection, so you can add a manual route like this:

route add -net 192.168.0.0 netmask 255.255.255.0 dev ppp0

Tadah! You can find other computers in the VPN!

For more advanced routing, eg: make your client’s local connections available to hosts local connections, I advise to take a look at this page full of knowledge. The beauty is that once the VPN connection is established, you can bridge pretty much all connections through using routing and iptables.

MySQL problems: Starting MySQL. ERROR! Manager of pid-file quit without updating file.

I stumbled across this error when I tried to import an InnoDB backup into my existing MySQL server.
I have one application that collects data that I need to tie to another set of data that is recorded on a different server through a different application.
It’s been rather challenging, cause I had to work of an InnoDB backup and they aren’t easily imported to another MySQL server, especially if you want to keep the data on that other server.

Okay, so what I tried, and ultimately prevented me from restarting MySQL was:

  1. changing all tables on the MySQL server to MyISAM
  2. killing MySQL (yes, I couldn’t stop it)
  3. copying the files in the MySQL DataDir to a backup location
  4. Copying the InnoDB backup files that I want to import into my DataDir
  5. trying to restart MySQL
But this is were the trouble started. The files couldn’t be imported and I had to roll back and use my backup files. But:

# sudo /etc/init.d/mysql start
Starting MySQL. ERROR! Manager of pid-file quit without updating file.

So I deleted the pointer file in /var/lock/subsys/

# sudo rm -f /var/lock/subsys/mysql
# sudo /etc/init.d/mysql start
Starting MySQL. ERROR! Manager of pid-file quit without updating file.

This didn’t work…
After long fiddling, I found out that the files in my DataDir have changed it’s owner, since I copied them as root to the backup location and back. They were now owned by root. So after:

# sudo chown mysql:mysql *
# sudo chgrp mysql *

I could do:

# sudo /etc/init.d/mysql start
 Starting MySQL. SUCCESS!

Hope this helps you too!

Installing Office 2007 on Ubuntu

This evening I thought I finally give installing Office 2007 another go. Not that I don’t like OpenOffice, but I often deal with files that have more than 65k lines…

I am no fan of Microsoft, but I must admit that the Office suite was always great. Probably that’s why it’s the only non native software that’s made it to the Mac…
I also got quite used to using the ribbon and it’s visually very pretty to work with MS.

So, I read that you should use an older wine version, namely 1.1.14, but I also read on the wine site that everything above 1.1.3 should also be suitable, so I will get the latest wine version Synaptic can find (which is 1.1.38). I will also install wine-gecko and I know we will need cabextract… The package manager thinks it’s wise to install a few other packages to, so here we go!

Good news: so far so good..
it starts the installation and asks for product key…
off to choose the programmes…
and the installation proceeds… (the installation is anything but quick…)

For the next step we need winetricks:
Get it by:

sudo wget www.kegel.com/wine/winetricks

So now we should be able to install a few windows repositories:

sh winetricks corefonts tahoma vcrun2005sp1 wsh56js

This will ask you a few time if it’s OK to install certain things and once completed, you need to configure wine:

winecfg

Find the libaries tab and add to new overrides:
riched20 & usp10
both will need the ‘Native (Windows)’ button ticked.

And off we go!
It installed in fine and it runs fine. Here is a screenshot:

Installing the Google debian / ubuntu repository (chrome / picasa)

I have found it difficult to find the line what exactly the line is that I need add to my /etc/apt/sources.list ... I finally found it on the Google site here.

But to spell it out:

# Google software repository
deb http://dl.google.com/linux/deb/ stable non-free main

If you are using the GUI, you can simply go to

Software Sources > Other Software > Add

and add the repositories this way. This should then also automatically provoke an update of the software sources…

There might get a warning saying that the package is unsigned. I haven’t tried, but from what I can see, there is a link on the Google page.

Video splitting with MEncoder

So now the question is how can you use MPlayer’s Mencoder to split a video file into chunks, or how can you just cut a scene out?

I haven’t really found an option to just cut it out in one go, but MEncoder is so fast, it’s easy to just cut twice, first the beginning:

mencoder -ss 00:13:11 -oac copy -ovc copy original.avi -o new.avi

Simply exchange the time (HH:MM:SS) with the ‘begin’ point of the new video. That copies all the rest of the file into a new one.
Now you need to trim the file to get the new end:

mencoder -endpos 00:01:11 -ovc copy -oac copy in.avi -o out.avi

This makes the file exactly 1 minute 11 seconds long.

With this method you can split any video in any number of smaller chunks.
Happy video sharing!

PS: I think I already showed how you can combine to videos, in case you wanna reverse the process, if not, I will post this soon.

Quake Live now for Linux

I have been playing ID software’s ego shooter since the years of Doom. Back then I wasn’t really ‘hooked’ and found ego shooter a rather dull waste of time.

Although, I did went on playing Doom 2 and it’s franchise, but again for lack of something better to do.

When I first saw Quake with it’s very pixelated graphics, I immediately disliked it. It wasn’t until me and my friends started patching computers into a network, using Coax cables at the time, that I learned that mouseaim and strafing opened a new dimension to Doom legacy…
When I then saw the game in GL mode, I realised the potential the game had… Shadows and pixel free animation was such a great improvement to the game.


Shortly afterwards I got hooked. I played all the expansions, with my favourite one being Painkiller, a multiplayer only mod. It featured the can of beans (gave you 100 HP, but made you fart), the bear trap and the gravity orb. It was good fun and we had lots of laughs when we were playing it some years ago. I even played Alien Quake, which was so dark and scary, it made me jump everytime I saw (or could hear) and enemy.


I played SO much that I was by far the best in my league of friends. I started playing online, even went to a few tournaments and bigger events.

Then came the long awaited Quake 2 in 1997.

It was different. A lot different. Apart from my usual problem of not having a high end machine to play the game, it was also a lot slower then Quake. The rocket launcher was not as strong anymore, the
jumps didn’t seem to be as powerful (although I found out that they were better than in Quake, but way too late) and noone really wanted to spend much time playing it.
Needless to say, I finished my way through the story mode and then never played it again. I saw people playing it on LAN parties, but I stuck to good old Quake or played Blobby :)…

Two years later, in 1999, ID software released the best ego shooter the world has seen to this day: Quake 3 Arena.


But at the time it was out and new and people were playing it religiously, I didn’t have a computer that was able to support that game. In later years, when it was still ‘in’, my computer was good enough to play it and I developed some half way decent skills. I played with friends till the early dawn, went out and played on LAN party tournaments and even got into moderate ranks from time to time.


But I couldn’t play online (because T-Online didn’t have a proper ping). The usual mods came out, within them a few really good one: Challenge Pro Mode Arena, another Painkiller and the engine was used in pretty much any ego-shooter you could think of.
In the meantime, Quake 3 developed into somewhat of a religion. Even girls were starting to play Quake 3! But it got worse: people weren’t afraid anymore to admit to being excessive gamers, in fact some even painted to logo on their skin:

(but there were also pretty ones)

A few years later and I had a very decent Quake 3 able machine, but guess what: nobody played anymore :(… I found a few people to give me a game on rare occasions, but these poor guys had no Quake experience and lost constantly, even when I tried to let them win. I had moved countries twice and playing with the old team was nearly impossible.

Eventually I migrated to Linux and by that time discovered OpenArena, which was good fun and had a nice community, but that community was small and you often couldn’t get games going. Still, I was very fond of the usual playmates 🙂

In my frustration I tried Quake 4, a title I actually bought – don’t ask me why…


Until I heated rumors about Quake Live: Quake 3 but browser based! How cool was that idea? I got my beta account fairly quickly and even installed Windoze to play it, but eventually gave up on the dual boot, as I never started Windows. Now, another 7 month down the line, there is a Linux native Firefox plugin for Quake Live. My prayers to the ID software god have been heard!


I haven’t been playing all that much, as i hardly have time for it. It’s still a great game and it’s always good to play it with some familiar faces…
I hope you will join me online for some frags soon. Play the best ego shooter in your bowser: Quake Live! If you want to connect with me, my in-game name is: d3ngar (surprise!).