Click Technology

Linux, Windows, Mac it's all good

Which version of Linux am I running?


How many times have I tried to find out _exactly_ which version of Linux I’m running when installing something?  I either get the kernel version (no good for adding debs etc) when I want to find out what the Debian underlying codename is and so on. Here then is the solution. All of it.

uname -a && cat /etc/*release
posted under Linux Tips | Comments Off on Which version of Linux am I running?

Burn an ISO to a USB stick


Every time I want to do this it seems to take waaay longer than it should. Here then, the instructions in n steps under Linux.

sudo lsblk

Check and see which device is your USB stick. In the commands below, the device is listed as /dev/sdaX, but in reality it will be /dev/sdc probably. Be careful. If you mis-select the device you could potentially DESTROY all your data, in which case you will have to go through all five stages of data recovery grief, namely..

Denial = “It wasn’t me

Anger = “How the fuck did I just do that? What was I thinking, cutting and pasting commands off the interwebs??

Bargaining = “If I reboot the machine, the data will probably come back. Actually, thats almost a certainty.

Depression = “Who suggested rebooting? What a stupid idea that was. I’m completely screwed. Why didn’t I do routine backups, especially of my thesis, my research, my entire music collection and all my photos since 2003.

Acceptance = “Either fork out for a data recovery company or start fresh with nothing.

Consider yourself warned. And also, make regular backups.

So, unmount the USB drive in question..

sudo umount /dev/sdX

Format it as FAT32

sudo mkdosfs -n 'usb-bootable' -I /dev/sdX -F 32

Run isohybrid..

sudo isohybrid /home/username/Downloads/systemrescuecd-x86-4.7.1.iso

Now burn the iso image to USB

sudo dd if=/home/username/Downloads/systemrescuecd-x86-4.7.1.iso of=/dev/sdX bs=4k

Flush data to the USB drive..

sudo sync

And eject the USB drive..

sudo eject /dev/sdX

Finished. Your USB pendrive is bootable and ready to go.

posted under Linux Tips | Comments Off on Burn an ISO to a USB stick

CSV mish mash


I’ve just found a fantastic new set of tools for handling CSV data.  CSVkit allows you to chop, change, splice and cut any csv file you like without all the Excel style overhead. All command line driven on Linux, this is a really fast tool for preparing CSV data for upload to a database.  Perhaps even cooler, once you have your data nicely prepared, you can even generate the SQL statements to create the database on your database server.  Very very sweet and massively time saving too.

As it’s a python too, get these in first..

sudo apt-get install python-dev python-pip python-setuptools build-essential

Then install with pip

sudo pip install --upgrade setuptools
sudo pip install --upgrade csvkit

I just downloaded a huge excel spreadsheet from the LSE with the list of all company names and details on the exchange.

Let’s convert that Excel file into csv

in2csv list-of-all-companies.xls > list-of-all-companies.csv

Nice. The first six or so lines are fluff, so let’s remove them

sed -e '1,6d' < list-of-all-companies.csv > list-of-all-companies-trimmed.csv

OK, great. Now there are a lot more things you could do, such as select the columns you want etc, but I’m just going to create the MySQL table for the CSV file. It can convert to any of these database formats – access, sybase, sqlite, informix, firebird, mysql, oracle, maxdb, postgresql & mssql. Sick.

Right, let’s create the table.

csvsql -i mysql list-of-all-companies-trimmed.csv


CREATE TABLE `list-of-all-companies-trimmed` (
	`List Date` FLOAT NOT NULL, 
	`Company` VARCHAR(35) NOT NULL, 
	`Group` FLOAT, 
	`Sector` VARCHAR(38) NOT NULL, 
	`Sub Sector` VARCHAR(39) NOT NULL, 
	`Country of Incorporation` VARCHAR(2) NOT NULL, 
	`Market` VARCHAR(11) NOT NULL, 
	`Mkt Cap £m` FLOAT, 
	`International Main Market` BOOL NOT NULL, 
	`FCA Listing Category` VARCHAR(8), 
	CHECK (`International Main Market` IN (0, 1))

Cut and paste this to your favourite SQL editor and execute on the server and voilà, instant data table. You can also have csvsql upload the table and data direct to the server too. Crazy sweet. A brilliant tool.

Time to read the documentation and tutorial for more info. Worth every minute.

posted under Linux Tips | Comments Off on CSV mish mash

Stereo problem…


I ripped a CD to mp3 files and tried to play them using Universal Media Streamer to my Yummyha CRX-N560D stereo, but it kept coming up with “unknown format” on the stereo display.  Oddly, other mp3 files were just fine.

Solution?  My stereo only plays mp3 with a bitrate of up to 256kb/s and these files were ripped at 320kb/s.  So how to change that?  Convert them using avconv and liblame to reduce the sampling frequency. Noice!

First install the Linux libav tools thus..

sudo apt-get install libav-tools

Now convert. This command resamples the songs, e.g. song-name.mp3 to song-name-out.mp3 at 256k and then moves song-name-out.mp3 to song-name.mp3 thus overwriting the original.

for f in ./*.mp3; do avconv -i "$f" -c:a libmp3lame -b:a 256k "${f%.*}-out.mp3" &amp;&amp; mv "${f%.*}-out.mp3" "${f%.*}.mp3"; done

The finished result is that all the files are there but now sampled at 256kb/s and play perfectly on my stereo. Sweet.

posted under General | Comments Off on Stereo problem…

Output a MySQL result set to a .csv file


This is quite sweet. You need to get some table data straight out to a CSV for manipulating in OpenOffice Calc, or similar products. But how?

Connect to your SQL server using a command line, ususally

mysql -u root -p

enter your password. Show your databases using


Switch to your database using

USE my_database_name;

Now show your tables if you like..


Now get your CSV out from the table results of a query thus..

SELECT Name, Surname, Address, Postcode, Telephone
FROM Customers
INTO OUTFILE '/tmp/customers.csv'

Et voila, data dumped to /tmp/customers.csv! Nice.


Perhaps my favourite XKCD cartoon.

Perhaps my favourite XKCD cartoon from

OK, funny / cool but how do I get .CSV file to my PC?

Understood.  I use Linux Mint, but in any Debian, Ubuntu, Mint system, open your file manager (or Thunar in Mint-speak) and put


Enter any password required for the target server and voilà, you’re on the /tmp directory on the target server!  From there, you can copy / paste the file as you wish,

posted under Linux Tips | No Comments »

Start a VirtualBox server in headless mode


Sometimes (in fact, why not every time?), you will want to start a server on your machine but not have it display a console. In other words, start it ‘headless’.

First, list all your machines. From the command prompt…

VBoxManage list vms

You get a list of all the machine images thus..

"Windows XP" {f0e63449-61bc-40e1-a82f-5a9bc6fb2434}
"Debian Basic" {b596b383-04e7-4895-bfaf-94a206f66960}
"Homestead_default_1407795525403_97441" {7abc2b40-5f57-4a6f-a647-8583c8790a62}
"UDA" {68999d0c-6391-4792-b13a-c120649ab240}
"PXE Boot" {fe1480eb-68d1-493a-9a90-6c36f819410e}
"Tiny Linux" {44ed7a1d-4e75-4d21-9bdd-a23699603af4}
"Turnkey Linux" {a2194ccb-c88d-48b9-aa6f-12b0805500c9}

So, to boot the Turnkey Linux box, just enter..

VBoxManage startvm "Turnkey Linux" --type headless

You should get

VBoxManage startvm "Turnkey Linux" --type headless
Waiting for VM "Turnkey Linux" to power on...
VM "Turnkey Linux" has been successfully started.

Now, just ssh straight onto the machine

ssh root@

Obviously, you need to know the ip address of the machine in advance or see your DHCP log to see what address it picked up. Otherwise, you’re ready to log in.

To shut it down again…

VBoxManage controlvm "Turnkey Linux" poweroff


Check out the well-written and compact documentation for VirtualBox here.

posted under Linux Tips | No Comments »
« Older Entries

This is my website for short blog posts and interesting materials that are noteworthy or have some handy-tip value.