Click Technology

Linux, Windows, Mac it's all good

Extract data from a photo


All pictures taken with digital cameras add information to images they take. A lot of information. To see it, install imagemagick using this command on the command line..

sudo apt-get install imagemagick

Then, just use the identify command thus..

identify -verbose /home/me/pics/some_picture.jpg

and it should pump out a heap of data.

Personally, if ever uploading photos to the internet (never) or emailing them to friends (rarely), I make sure to strip all the data from them. For this, use mogrify, also from the imagemagick suite…

mogrify -strip /home/me/pics/some_picture.jpg

Now the exif data has been removed. Nice!


True dat..

posted under Linux Tips | No Comments »

Mount a CD in Linux


This works for any version of Linux as it’s a universal command and is very simple.

First, su as root

$sudo su

Now create the directory where you want to see the CD/DVD files..

# mkdir -p /media/mycd

Now use the mount command to mount the CD

# mount -o loop /path/to/my/iso/my_favourite.iso /media/mycd

The files are now visible in /media/mycd.


posted under Linux Tips | No Comments »

Create an iso image from a CD..


Two steps…

isoinfo -d -i /dev/cdrom | grep -i -E 'block size|volume size'

You get this output…

Logical block size is: 2048
Volume size is: 1620057

Using this information, we insert the numbers into the dd command..

dd if=/dev/cdrom of=/home/user/iso_files/test.iso bs=2048 count=1620057

And that’s it. Happiness!

posted under Linux Tips | No Comments »

Backing up and restoring hard disks & partitions


Here’s a slightly longer article than ususal on the subject of hard disks and partitions. This is always a subject that is occasionally tricky. Here’s the nutshell of how to find your hard disk name, the relevant partition and how to back it up and restore it.

Listing the disks and partitions

To list the hard disk devices on your system use..

sudo fdisk -l

You should get an output something similar to this…

Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 Köpfe, 63 Sektoren/Spur, 15566 Zylinder, zusammen 250069680 Sektoren
Einheiten = Sektoren von 1 × 512 = 512 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Festplattenidentifikation: 0x00055cbf

   Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sda1   *        2048      495615      246784   83  Linux
/dev/sda2          497662   250068991   124785665    5  Erweiterte
/dev/sda5          497664    23932927    11717632   83  Linux
/dev/sda6        23934976    27838463     1951744   82  Linux Swap / Solaris
/dev/sda7        27840512   250068991   111114240   83  Linux

Disk /dev/mapper/sda5_crypt: 12.0 GB, 11996758016 bytes
255 Köpfe, 63 Sektoren/Spur, 1458 Zylinder, zusammen 23431168 Sektoren
Einheiten = Sektoren von 1 × 512 = 512 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Festplattenidentifikation: 0x00000000

Festplatte /dev/mapper/sda5_crypt enthält keine gültige Partitionstabelle

Platte /dev/mapper/cryptoswap: 1998 MByte, 1998585856 Byte
255 Köpfe, 63 Sektoren/Spur, 242 Zylinder, zusammen 3903488 Sektoren
Einheiten = Sektoren von 1 × 512 = 512 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Festplattenidentifikation: 0x67218b8c

Festplatte /dev/mapper/cryptoswap enthält keine gültige Partitionstabelle

Disk /dev/sdb: 32.0 GB, 32019316736 bytes
255 Köpfe, 63 Sektoren/Spur, 3892 Zylinder, zusammen 62537728 Sektoren
Einheiten = Sektoren von 1 × 512 = 512 Bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Festplattenidentifikation: 0xc3072e18

   Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sdb1              32    62537727    31268848    c  W95 FAT32 (LBA)

As you can see, the first disk name is /dev/sda and this disk is 128GB in size. Listed further down are the details of how the disk, /dev/sda, is sliced up, namely the five partitions sda1, sda2, sda5, sda6 and sda7.

There’s also another disk, /dev/sdb which is 32GB. It has one partition, /dev/sdb1.

From this we can see that the disk is alsways called something like /dev/sda, /dev/sdb, /dev/sdc and so on.  The partitions are always numbered sub items, so /dev/sdb1, /dev/sdb2, /dev/sdb3, /dev/sdb4 and so on as needed.

Back up the paritions or disks..

We back up the partition or disk using the dd command. Let’s backup the boot partition, /dev/sda1, on the disk /dev/sda to the partition /dev/sdb1 on the disk /dev/sdb.  We know /dev/sda1 is the boot partition because it’s marked with an asterisk (*).

So, device /dev/sdb is a USB memory stick. To backup the boot parition, /dev/sda1, to the USB drive, /dev/sdb, let’s mount the USB drive first using the following commands.

First, make a target folder for the mount..

sudo mkdir -p /media/any/path/you/like

Now, we mount the partition /dev/sdb1 to the target location /media/any/path/you/like so that when we change directory to /media/any/path/you/like, the contents of the USB disk are visible.

For this, we use the mount command. The mount command syntax is effectively mount which_device where. We’ll use the following mount command.

sudo mount -t vfat -o rw,users /dev/sdb1 /media/any/path/you/like

The command above states that the filesystem of the USB disk is vfat and is read/write-able and can be dismounted by users.

Ready to backup

Now the disk is mounted, we can dd our data straight to it.

sudo dd if=/dev/sda1 of=/media/any/path/you/like/the_sda1_partition_backup

Once running, nothing appears to happen. Remain calm and wait. Losen any tight clothing if necessary and wait. Backup is happening. When it ends, you’ll get something like this…

493568+0 Datensätze ein
493568+0 Datensätze aus
252706816 Bytes (253 MB) kopiert, 6,09949 s, 41,4 MB/s

For style points, you can also backup the whole disk to another hard disk of the same size and dimensions..

sudo dd if=/dev/sda of=/dev/sdb

Or even back up a partition or disk to a compressed file to save space.

sudo dd if=/dev/sda1 | gzip > /media/any/path/you/like/the_sda1_partition_backup.gz

You will probably need to sudo su before running the command above, so first,

sudo su

and then use the dd command above.

That’s it. You’re a pro. Drinks all round.

posted under Linux Tips | No Comments »

Rotate logs


Sometimes you will need to force logs to be rotated. No problem. This can be done manually. Here’s the command.

logrotate -v -f /etc/logrotate.d/rsyslog

This will compress and rotate all the significant logs.

To check which logs your machine will rotate, examine the file /etc/logrotate.d/rsyslog



posted under Linux Tips | No Comments »

Set up CodeIgniter quickly…


The CodeIgniter framework is great, even the documentation is spot on being short and to-the-point.

They have installation instructions, sure, but here’s the commands to download it and set it up with the folders in the correct place.

First step, log into your server over SSH. I assume you are using Apache in this process for the web configuration, and that your root folder for serving web files is /var/www as is typical.

If you’re using nginx or something else, server side config is still straightforward, just a question of setting your document root AFAICS.

Here’s the steps..

This will download the CodeIgniter yip, unpack it, set it up, add a .htaccess file, set up the database connection and make you feel good about yourself generally. Use with the ususal care and attention.

cd /var/www
sudo rm -rf /var/www/
sudo mkdir /var/www/
cd /var/www/
sudo wget --output-document=./
sudo unzip
sudo rm
sudo mv ./CodeIgniter_2.2.0 ./public_html
sudo mv ./public_html/system/ ./
sudo mv ./public_html/application ./
sudo sed -i s/"$system_path = 'system';"/" = '\/var\/www\/\/system';"/g ./public_html/index.php
sudo sed -i s/"$system_path = 'application';"/" = '\/var\/www\/\/application';"/g ./public_html/index.php
sudo su -c $'echo "RewriteEngine on" >> /var/www/'
sudo su -c $'echo "RewriteCond \$1 !^(index\.php|images|robots\.txt)" >> /var/www/'
sudo su -c $'echo "RewriteRule ^(.*)$ /index.php/\$1 [L]" >> /var/www/'
sudo sed -i s/"\$autoload\['libraries'\] = array('');"/"\$autoload\['libraries'\] = array('database');"/g /var/www/
sudo sed -i s/"\$db\['default'\]\['username'\] = '';"/"\$db\['default'\]\['username'\] = 'your_database_username_for_your_codeigniter_app';"/g /var/www/
sudo sed -i s/"\$db\['default'\]\['password'\] = '';"/"\$db\['default'\]\['password'\] = 'your_database_password_for_username_above';"/g /var/www/
sudo sed -i s/"\$db\['default'\]\['database'\] = '';"/"\$db\['default'\]\['database'\] = 'my_codeigniter_app_database';"/g /var/www/
sudo su -c $'chown -R www-data:www-data /var/www/'
sudo su -c $'find /var/www/ -type f -print0 | xargs -0 chmod 0664'
sudo su -c $'find /var/www/ -type d -print0 | xargs -0 chmod 0775'
sudo su -c $'service apache2 restart'

OK, that’s it. Start working on the app. The part below was a step by step for the apache side of things when I wrote the article earlier, so I’ll leave it here for inspection. As far as you’re concerned, the CodeIgniter app is ready to go.

All you need to do now is configure your apache server. You’re using virtual hosts? Great. here’s the code..

Create the site configuration file…

sudo touch /etc/apache2/sites-available/

Open it for editing (say with vim or your favourite editor)

sudo vim /etc/apache2/sites-available/

Paste in the code below…

<virtualhost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/
                Options FollowSymLinks
                AllowOverride None
        <directory /var/www></directory>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined

Save and close the file with


Now create a symlink from the sites-available to the sites-enabled folder to make the site appear…

sudo ln -s /etc/apache2/sites-available/ /etc/apache2/sites-enabled/

.. and restart apache..

sudo service apache2 restart


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.