Linux

Remove vim color coding in Ubuntu

By default Ubuntu’s vim utility is configured to color code certain keywords, comments, extensions, etc.

I personally do not like this. So I just disable that feature. And while I am at it, I also enable the ruler, which displays the line number and the character position of the cursor.

To do that for all users, edit the /etc/vim/vimrc file add the following lines to it:

syntax off		" Clear any font/color/hilighting
set ruler		" Enable the ruler

If you want to do that just for a particular user, create a .vimrc file in that user’s home directory (if it does not already exist) and add the same lines to it.

Monday, November 7th, 2011 Linux, Ubuntu 1 Comment

How to enable the ath9k wireless driver on Ubuntu Lucid (10.04)

Ath9k is the latest wireless driver for the newer Atheros chipsets and just like the MadWifi driver could be used to put your NIC in a promiscuous mode, do packet injection, etc. in order to crack WEP.

Check the compatibility of your wireless NIC first.
To find out what kind of chipset you have, run:

lspci | grep -i wireless

The ath9k driver is present in any kernel starting with version 2.6.27. The oldest supported ath9k version comes with kernel 2.6.32. That means most likely you already have the driver and there is no need to download it, all you have to do is enable it.

The general steps in order to enable ath9k are:

  1. Get the kernel source and some necessary packages
  2. Configure the kernel
  3. Compile and install the kernel
  4. Configure grub to boot from the new kernel image

Some steps might sound a bit intimidating, but actually they are very easy to do.

Since you will be running a lot of commands as root, it would be more convenient to open a bash shell as root instead of preceding all commands with sudo. The easiest way to do this is to run the following command it terminal:

$ sudo bash

Note: The above command has nothing to do with enabling the root login. I strongly recommend to never enable the root login due to serious security risks! Some blogs might ask you to do that, but there is hardly ever any reason to do this.

1. Get the kernel source and some necessary packages

# aptitude install git-core build-essential kernel-package qt3-dev-tools libqt3-mt-dev fakeroot
# apt-get install linux-source 

The above command downloaded the kernel source tarball in /usr/src.
In my case the kernel version I am working with is 2.6.32 (patch level 15). Replace these numbers with the version of your kernel source.
Now lets cd to the place we downloaded the kernel source:

# cd /usr/src

Uncompress and extract the kernel source:

# tar xjvf linux-source-2.6.32.tar.bz2
# cd linux-source-2.6.32

2. Configure the kernel

Before configuring the kernel, lets import the configuration of the currently running kernel. This way we do not miss to enable something we currently have and need:

# cp -vi /boot/config-`uname -r` .config

Now we are ready to add a few configurations to the kernel:

# make xconfig

This opens up an xwindow with a hierarchical structure representing the kernel settings:

Linux Kernel Configuration

Linux Kernel Configuration

First enable mac80211:

Networking  --->
  Wireless  --->
     Improved wireless configuration API
     Generic IEEE 802.11 Networking Stack (mac80211)

You can then enable ath9k in the kernel configuration under:

Device Drivers  --->
  [*] Network device support  --->
        Wireless LAN  --->
             Atheros 802.11n wireless cards support

If you re-used the existing configuration, note that Ubuntu kernels build with debugging information on, which makes the resulting kernel modules (*.ko files) much larger than they would otherwise be. To turn this off, go into “Kernel hacking”; then, under “Kernel debugging”, turn OFF “Compile the kernel with debug info”.

Save changes and exit.

3. Compile and install the kernel

First, let’s ensure a “clean” build:

# make-kpkg clean

Since the kernel compilation might take some time, it is best to set the CONCURRENCY_LEVEL variable, so that it can take a full advantage of the multiple processors or mulitple CPU cores on the machine. The CONCURRENCY_LEVEL variable is equal to the number of processors on the machine plus one. So if your machine has a dual core processor the variable will be equal to 3. To find out how many processors or cores your computer has run:

# lshw -C CPU

In my case I get cpu:0 and cpu:1, which means that I have a dual core processor.
Besides the CONCURRENCY_LEVEL, the only other thing we need to pay attention to here is the “–append-to-version” option. It basically adds that string to the end of the kernel name and could be set to anything. That gives you the opportunity to put there something meaningful to distingush the kernel from the other ones. In this case I called it “-mykernel”.

Now you are ready to compile:

# CONCURRENCY_LEVEL=3 fakeroot make-kpkg --initrd --append-to-version=-mykernel kernel-image kernel-headers

If you want to see the ubuntu splash screen (or use text mode) before you get to X instead of just a black screen, you’ll want to make sure the framebuffer driver loads:

# echo vesafb >> /etc/initramfs-tools/modules
# echo fbcon >> /etc/initramfs-tools/modules

Now install the kernel and the headers from the created Debian packages:

# dpkg -i linux-image-2.6.32.15+drm33.5-mykernel_2.6.32.15+drm33.5-mykernel-10.00.Custom_i386.deb
# dpkg -i linux-headers-2.6.32.15+drm33.5-mykernel_2.6.32.15+drm33.5-mykernel-10.00.Custom_i386.deb

Now let’s generate an initramfs (initrd) image, that will be loaded up by grub on boot:

# cd /boot

To avoid confusion with the next command, here is what my /boot directory contains before I run the mkinitramfs command:

# ls -altr
total 27700
-rw-r--r--  1 root root  160280 2010-03-23 05:37 memtest86+.bin
-rw-r--r--  1 root root 4034976 2010-08-20 14:22 vmlinuz-2.6.32-24-generic
-rw-r--r--  1 root root 1689036 2010-08-20 14:22 System.map-2.6.32-24-generic
-rw-r--r--  1 root root  115905 2010-08-20 14:22 config-2.6.32-24-generic
-rw-r--r--  1 root root  651618 2010-08-20 14:22 abi-2.6.32-24-generic
-rw-r--r--  1 root root    1196 2010-08-20 14:24 vmcoreinfo-2.6.32-24-generic
drwxr-xr-x 22 root root    4096 2010-09-04 15:27 ..
-rw-r--r--  1 root root       0 2010-09-07 22:11 initrd.img-2.6.31-wl
-rw-r--r--  1 root root 7977082 2010-09-07 22:49 initrd.img-2.6.32-24-generic
-rw-r--r--  1 root root  115845 2010-09-08 02:13 config-2.6.32.15+drm33.5-mykernel
-rw-r--r--  1 root root 3999488 2010-09-08 07:38 vmlinuz-2.6.32.15+drm33.5-mykernel
-rw-r--r--  1 root root 1644782 2010-09-08 07:38 System.map-2.6.32.15+drm33.5-mykernel
drwxr-xr-x  3 root root    4096 2010-09-08 16:01 .

Run the mkinitramfs to generate the initrd:

# mkinitramfs -k -o initrd.img-2.6.32.15+drm33.5-mykernel 2.6.32.15+drm33.5-mykernel

4. Configure grub to boot from the new kernel image

# update-grub2

The last thing to do is to ensure that the ath9k module loads on boot. That will avoid running modprobe ath9k after each reboot.
So lets add the line ath9k to the end of the /etc/modules file:

# echo ath9k >> /etc/modules

Now reboot your computer and chose the new kernel to boot into from the grub menu.

Your wireless NIC should be working now using the ath9k driver.


Credits:

Friday, September 17th, 2010 Linux, Ubuntu 15 Comments

Change the date and time (or any other EXIF image meta-data) of pictures with Ubuntu

There is a very flexible and easy Linux tool that helps you change the EXIF meta-data of images. It allows you to change individual files or whole bunch of them with one command. You can also put different rules about what files and how you want to change them if you need to.

The program is called exiftool. So let’s install it first.

In terminal execute:

sudo apt-get install libimage-exiftool-perl

Now you are ready to start changing the meta-data of the images.

For example, if I wanted to change all the dates and times (DateTimeOriginal, CreateDate and ModifyDate) of the IMG_01.jpg file to the 8th of August 2010 at 3:35:33 PM I would do:

exiftool -AllDates='2010:08:08 15:35:33' -overwrite_original IMG_01.jpg

If I wanted to change the dates on all the files in the “images” directory, I would do:

exiftool -AllDates='2010:08:08 15:35:33' -overwrite_original images

The “-overwrite_original” option is necessary if you want to change the meta-data of the original images. If you omit that option, then exiftool will back-up the originals by making a copy of them and adding “_original” to the end of the file names.

If you want to change the dates to all the files in the “images” directory that were taken by a Cannon camera (and not touch the rest) I would do:

exiftool -AllDates='2010:08:08 15:35:33' -if '$make eq "Canon"' -overwrite_original images

As far as changing dates and times, there is another option of exiftool that lets you do time calculation.

For example, the other day I found out that my camera’s time was correct but the date was ahead by 30 days. That meant that all the photos I had taken lately had dates that were off by exactly 30 days. If I were to use the above examples I could set the dates individually (which would be a long and tedious process) or set all the images to the same date and time (which would be wrong). In this case I used the date calculating option and just executed:

exiftool -AllDates-=720:00 -overwrite_original images

That command subtracts 720 hours (30 days) off the dates of each image file in the images directory. Now every image has the exact date and time it was taken.

I have only scratched the surface of what this tool is capable of. For more information look at the man pages of the exiftool command.

Wednesday, August 11th, 2010 Linux, Ubuntu 1 Comment

Just Upgraded my Nexus One from Android 2.1 to Android 2.2

The latest Android OS version 2.2 (“Froyo”) was announced at the Google I/O conference on the 11th of May. As you already probably know it adds multiple enhancements like tethering, wifi hotspot functionality, full support for Flash, etc. Since I use my Nexus One phone for Android development, I did not want to download the update from Google and then install it with adb. I just wanted to wait for the over the air update.

And to my surprise, the first time I looked at my phone this morning, I had this message on the screen:

Android 2.2 Upgrade Message

Android 2.2 Upgrade Message

I was not sure how long it would take, so I just hit “Install Later”. Then a couple of hours later, when I was ready, I just went to Settings -> About Phone -> Software Update and hit “Restart & Install”:

Android 2.2 Settings -> About Phone -> System Updates

Android 2.2 Settings -> About Phone -> System Updates

The phone rebooted and started the upgrade. The whole process with the installation took less than 5 minutes.

I am not going to go into details what the features of Android 2.2 are. There are so many announcements and blog posts on this matter already out there…

But what I am going to say is that Android is the leading OS in the mobile phone market right now. I can say this definitively, since I have been using iPhones for the past 2 years. I have a 3G and a 3GS phones. I encourage any iPhone user to go and check out an Android device. Please do not look at the low end hardware that runs Android (like the Cliq, the old G1, etc.). Check out the HTC Evo, the HTC Incredible, the Nexus One etc. See for yourselves before you make your decision to get another phone and lock into a 2 year contract. I will mention only a few things you will discover on the Android device that your phone probably does not have right now:

  1. Turn by turn voice navigation
  2. Built in tethering
  3. Built in WiFi hotspot capability supporting multiple devices
  4. Full support for Flash
  5. Full blown multitasking on the OS level (no need for the programmer to do anything special)
  6. Integrated speech recognition across the board. Voice input could be used anywhere in place of the text input.
  7. Over the air updates and syncing. That means no iTunes or the like!

And many other features that I do not want to get into details right now. I am sure you can fill in the gaps for yourselves…

Friday, July 2nd, 2010 Android, Apple, Linux No Comments

Find the Geopgraphical Location of an IP Address

There are a few applications that give the geographical location of an IP address *. My favorite one is VisualRoute. It not only maps the location of the source and destination IP addresses, but also all the hops in between. The down side to it is that it is not available for Linux and it costs $50 per user.

The http://mapulator.com site gives you pretty much the same information online for free, but it has been down for quite some time now.

Lately I have been using http://whatismyipaddress.com/ip-lookup. But it only maps the destination IP address.

If anyone knows of a Linux application that would map all the hops and the final IP destination, please leave a comment!

* IP addresses do not have a geographical location per se. Any program that maps IP addresses can only give you where the whole class of IP addresses (that the specified IP address belongs to) is registered to be located at. They do this by querying a database that has that information. This is accurate down to a city level at best. Do not expect to find where someone lives by their IP address!

Monday, June 28th, 2010 Linux, Networking No Comments

Search

 

Archive

May 2012
M T W T F S S
« Mar    
 123456
78910111213
14151617181920
21222324252627
28293031  

Other