Howto remap keyboard keys in Linux

Almost two years since I wrote a blog post, but learnt a lot in these past two years. I’ll be writing everything I can remember in the coming days, but first, I need to record down something I learnt recently.

I came across one challenge to generate a key press event where the key is not at all in the normal US keyboard. That special key (Hangul/English Toggle key) is only available in Korean Keyboard. So, here is how I did

We need to choose any one key available in the normal US keyboard and remap it to produce Hangul/English Toggle Key’s code. For my purpose I’m going to remap F7 key to produce Hangul/English keypress events. First, I need to know what F7 produces when it gets pressed. There is a tool called “evtest” which will show the code generated by physical keyboard

Event: time 1496043435.462606, type 4 (EV_MSC), code 4 (MSC_SCAN), value 41
Event: time 1496043435.462606, type 1 (EV_KEY), code 65 (KEY_F7), value 0

Here, the MSC_SCAN value of “41” (hexadecimal) is the code generated by the physical keyboard. Using this value. we need to create one file (/usr/lib/udev/hwdb.d/63-keyboard.hwdb) with the following content

keyboard:name:AT Translated Set 2 keyboard:dmi:*

Here, The first line starting with “keyboard:” indicates the name of the keyboard. There are lot of way to match the keyboard (see /usr/lib/udev/hwdb.d/60-keyboard.hwdb file for more details). The second line which starting with “KEYBOARD_KEY_” should have one space before “KEYBOARD”. The “hangeul” string at the end of the second line is a suffixed lowercase substring of a macro defined in /usr/include/linux/input-event-codes.h file. You can use more than one “KEYBOARD_KEY_=” lines to remap the keys in your physical keyboard.

Once you create the 63-keyboard.hwdb file. Run the following command to update /etc/udev/hwdb.bin file which is used by udev

sudo udevadm hwdb --update

Once the hwdb.bin file updated, Either reboot your machine or trigger udev events for the particular keyboard (here, /dev/input/event1 may vary depend on your keyboard devfile mapping)

sudo udevadm trigger /dev/input/event1

Once you have the remapping, you can test it again with evtest.

Event: time 1496046275.166879, type 4 (EV_MSC), code 4 (MSC_SCAN), value 41
Event: time 1496046275.166879, type 1 (EV_KEY), code 122 (KEY_HANGUEL), value 0

In the above output, MSC_SCAN value “41” generates “KEY_HANGUEL” instead of “KEY_F7”.

Update (2018-02-06):

I recently have to remap Left Window Key to Right Window Key. So I created a new file in /etc/udev/hwdb.d/92-keyboard-override.hwdb and added following lines

# keyboard overrides

# laptop keyboard

# USB keyboard

Here KEYBOARD_KEY_dd=rightmeta changes Menu key to Right Window Key, KEYBOARD_KEY_db=rightmeta and KEYBOARD_KEY_700e3=rightmeta both changes Left Window Key to Right Window Key but former is for laptop keyboard and later is for USB keyboard.

howto change font in linux using fontconfig

To those who are not familier to fontconfig, it is the library which provides fonts to each program in your linux desktop (atleast in gnome3). It maintains the details about all the font files available in your linux box and provides best matched font when your program requests a specific type of font.

If you use only english in day-to-day activities, fontconfig dont come in your way, but its a nightmare if you are a multilingual user. Even if you are a multilingual user, fontconfig tries its best to make your life easy by matching the best font for your language automatically, but the pain starts if you don’t like what fontconfig provides and want to change the default font for your language to something which looks good in the editor.

I went through the pain and want to share what I did to fix. For me, fontconfig said “TAMu_Kadambari” is the best font for “Tamil” and gedit by default shows tamil fonts using “TAMu_Kadambari”. But, this font doesn’t look good in gedit. After much research, I’m able to change the default font for “Tamil” language from “TAMu_Kadambari” to “TAMu_Kalyani” using this xml file.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!--save this file as ~/.config/fontconfig/fonts.conf-->
<test name="lang">
<edit name="family" mode="assign">

Here, the <match> tag contains one test which checks if the provided language is “Tamil” (lang=ta). If it is, then edit the original request coming from the application and assign family name as “TAMu_Kalyani”(family=TAMu_Kalyani) so that fontconfig matching algorithm will match only “TAMu_Kalyani”.

Thats it, my gedit now picks “TAMu_Kalyani” and it looks good. More details about fontconfig is available here.

fontconfig uses patterns for its matching algorithm, and it goes like this

<families>-<point sizes>:<name1>=<values1>:<name2>=<values2>..

for example, here is how you can check which is the best matched font available in your system for language “Tamil”. Output also contains top 10 ranked fonts for tamil. The first preferred font is “TAMu_Kalyani”, because I have overridden in ~/.config/fontconfig/fonts.conf

[mohan@mohanlaptop0 ~]$ fc-match -s 'monospace-10:lang=ta' | head
TAMu_Kalyani.ttf: "TAMu_Kalyani" "Regular"
TSCu_Comic.ttf: "TSCu_Comic" "Normal"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
Pothana2000.ttf: "Pothana2000" "Pothana2000"
MalOtf.ttf: "MalOtf" "Book"
TSCu_Paranar.ttf: "TSCu_Paranar" "Regular"
SyrCOMAdiabene.otf: "East Syriac Adiabene" "Regular"
SyrCOMKharput.otf: "Serto Kharput" "Regular"
[mohan@mohanlaptop0 ~]$

If I remove ~/.config/fontconfig/fonts.conf, it goes back to the original behaviour and provides “TAMu_Kadambari” as preferred font for “Tamil”

[mohan@mohanlaptop0 ~]$ fc-match -s 'monospace-10:lang=ta' | head
TAMu_Kadampari.ttf: "TAMu_Kadambri" "Regular"
TAMu_Kalyani.ttf: "TAMu_Kalyani" "Regular"
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
Pothana2000.ttf: "Pothana2000" "Pothana2000"
MalOtf.ttf: "MalOtf" "Book"
TSCu_Comic.ttf: "TSCu_Comic" "Normal"
TSCu_Paranar.ttf: "TSCu_Paranar" "Regular"
[mohan@mohanlaptop0 ~]$

fontconfig configuration files are very versatile and one can do lot of things, but we need to first understand its patterns to do anything useful. Anyway, I hope this article provide good example for fc-match command-line tool and fontconfig patterns.

Virtual Home Network (with Dnsmasq , Bridge, TUN/TAP, Qemu)

As I said in my previous article, this post will explain how we can use bridge interface to configure networks inside virtual hosts and much more about virtualization.

First we need to make sure our machine is capable of kvm virtualization, see if you get any output for below command

$ grep -E 'vmx|svm' /proc/cpuinfo

Most modern processers supports Hardware assisted Virtualization. If you don’t get any output for above command, It means you don’t have a processor capable of providing Hardware Assisted Virtualization. Qemu-kvm will not work, but you can use Qemu without kvm or some other virtualization applications like virtualbox etc. Also skip ‘LOADING KERNEL MODULES’ section of this article if you don’t have kvm support.


If your processor supports kvm, then we have to load following kernel modules and make sure they load automatically whenever we restart our system. In gentoo/sabayon, we need to modify ‘modules=’ line in /etc/conf.d/modules file as

modules="kvm-intel tun"

Here ‘kvm-intel’ is the kernel module for virtualization and ‘tun’ is the kernel module for ‘TUN/TAP’ devices. For, AMD machines, we need to load ‘kvm-amd’ instead of ‘kvm-intel’. Now we need to load these modules for the current run, Here is the commands which will load ‘kvm-intel’ and ‘tun’ drivers into kernel

$ sudo modprobe kvm-intel tun


Next is to install required packages, Here is sabayon command to install required packages

$ sudo equo install app-emulation/qemu-kvm net-misc/bridge-utilities net-dns/dnsmasq sys-apps/usermode-utilities

‘qemu-kvm’ is for virtualization, ‘bridge-utilities’ is to get ‘brctl’ command, ‘dnsmasq’ is to handle DNS and DHCP requests from guests, ‘usermode-utilities’ is to get ‘tunctl’ command.


Its time to create interfaces, first we need to create the bridge

$ sudo brctl addbr br0

Assign IP address to the bridge,

$ sudo ifconfig br0 netmask up

Next, create a tap0 interface, following command will create ‘tap0’ pseudo slave interface from /dev/net/tun master interface

$ sudo tunctl -t tap0

Now, we need to hook the tap0 interface with the bridge br0

$ sudo brctl addif br0 tap0

Bring up the tap0

$ sudo ifconfig tap0 up


If you read my previous article, I have dnsmasq configured to serve DHCP requests coming from br0. Hooking tap0 into br0 will make the guest send DHCP requests via tap0->br0 and my host machine’s dhsmasq process will serve ip address to the guest. We have to make sure iptables dont block BROADCAST packets as well as open the port 53 and 64 so that dnsmasq will get the DHCP and BOOTP packets. Make sure your iptables contains following lines,

$ sudo iptables -t filter -L | grep -E 'BROADCAST|domain|bootp'
ACCEPT     all  --  anywhere             anywhere             ADDRTYPE match src-type BROADCAST
ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domainflags: FIN,SYN,RST,ACK/SYN
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootpsflags: FIN,SYN,RST,ACK/SYN

Now we need to make sure MASQUERADING is enabled and let your host system forward the packets. Also make these settings permanent so that reboot dont break the settings,

$ sudo iptables -t nat -A POSTROUTING -j MASQUERADE
$ sudo sysctl net.ipv4.ip_forward=1
$ sudo /etc/init.d/iptables save
$ sudo /etc/init.d/iptables reload
$ sudo sed -i 's/^.*net.ipv4.ip_forward.*$/net.ipv4.ip_forward = 1/g' /etc/sysctl.conf

Check these settings are ok,

$ sudo iptables -t nat -L
target     prot opt source               destination         
MASQUERADE  all  --  anywhere             anywhere
$ sudo sysctl -a | grep ipv4.ip_forward
net.ipv4.ip_forward = 1


Finally, its time to start virtual guest, first we need to create disk image, Here is the command to create a 5GB raw disk image for qemu-kvm

$ sudo qemu-img create -f raw Debian.img 5G

Now download debian netinstall image for amd64 architecture

$ sudo wget

Atlast, start the guest with with tap0 networking

$ qemu-kvm -cpu kvm64 -drive file=Debian.img,if=virtio -cdrom mini.iso -boot order=dc -m 512 -soundhw sb16 -name "Debian" -net nic,model=virtio -net tap,ifname="tap0",script=no,downscript=no

Thats it, your qemu guest will automatically get network settings from host machine. You can also verify that dnsmasq served a DHCP request via syslog

$ sudo grep 'dnsmasq-dhcp' /var/log/messages
dnsmasq-dhcp[9810]: DHCPDISCOVER(br0) 52:54:00:12:34:56
dnsmasq-dhcp[9810]: DHCPOFFER(br0) 52:54:00:12:34:56
dnsmasq-dhcp[9810]: DHCPREQUEST(br0) 52:54:00:12:34:56
dnsmasq-dhcp[9810]: DHCPACK(br0) 52:54:00:12:34:56 virt0

Well, if you still reading this article and not get bored, you must be a *nix admin. Have a great day!!

Aircel GPRS with Linux and Bluetooth

Ah!! finally, I bought a new mobile. its Nokia 2730c,

But my struggle started here with my service provider, My main reason to bought this particular phone is to get Internet access at my home. So that I can #join at anytime. But it was a tough ask with Aircel.

At first, when I inserted my SIM card, lot of activity happens and I got a message from Aircel saying to save a settings message. After that, I received a settings message saying “Pocket Internet”. I already know that there is a service provided by Aircel called “Pocket Internet” to access internet in mobile, But when I searched more about “Pocket Internet”, I came to know that I can’t connect to my PC and browse, because “Pocket Internet” is a WAP service.

So I called CustCare, but as I expected, those guys are dump about what I’m talking, First I asked whether I can connect my PC and use “Pocket Internet” for browsing? but no clear answers from them. After 2 calls, I called one more time, this time, CustCare person informed that I need to configure my phone to access “Aircel GPRS”, he also informed that if your phone is capable, the settings would have already came.

I was shocked, because my Nokia 2730c is a 3G capable mobile, but I didn’t receive ‘Aircel GPRS’ settings, only I received “Pocket Internet” settings. I was nearly at the edge to change my provider. Whenever I call them, they are not at all listening to my words, they simply saying that my mobile is not capable. I got frustrated and stopped calling them, after 2 days, I called them thinking that it would be my last call, thankfully that person responded me in a positive manner, they already have my call history and he is able to understand what my problem is, The exact problem is simple,

“Aircel didn’t have settings for Nokia 2730c, because its a new model”

So, I didn’t receive “Aircel GPRS” settings when I inserted my SIM. Thanks to that person, he raised a ticket to their technical team, and they rectified this issue next day itself. Day after that day, I received “Aircel GPRS” settings. and connected to “Nokia OVI store” using “Aircel GPRS” Access Point in my mobile.

First phase of this struggle is over, here comes the next,

It would have been a simple task if I’m a windows user, connect my mobile to laptop, use PC suite to dial-up and access internet, thats all. But, Its a task up to me to get the ppp settings from Aircel. Thankfully Ubuntu guys have a very good writeup for aircel. It makes easy for me to use ‘pppconfig’ and create ‘/etc/ppp/peers/aircel’ file and ‘etc/chatscripts/aircel’ file. Here is the steps,

root@Debian:/etc/ppp/peers# aptitude install pppconfig
root@Debian:/etc/ppp/peers# pppconfig aircel
select "Create a Connection named aircel" and select "Ok"
select "Dynamic DNS" and select "Ok"
select "PAP" and select "Ok"
give username as "Aircel" and select "Ok"
give password as "aircel" and select "Ok"
pppconfig will give speed of your modem as 115200, use this default
Select "Tone" and select "Ok"
give phone number as *99***1#
Next step will be giving the modem name, I'm going to use /dev/rfcomm0 (bluetooth serial device) so I selected "No" and gave '/dev/rfcomm0' as my modem name.
Finally select "Finished Write files and return to main menu", two files will be created, only will be '/etc/ppp/peers/aircel' and another one is '/etc/chatscripts/aircel'
select "Quit"

Now, I need to modify the ‘/etc/chatscripts/aircel’ file and insert the following lines after ‘ATZ’ init line. These two lines specifies Aircel’s APN aka Access Point Name which is ‘’, I think if you are using Aircel’s postpaid service, then you need to give ‘aircelgprs.po’. But check your mobile’s “Aircel GPRS” settings first, it will clearly tell Access Point Name.

'' "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
'' AT+CGDCONT=1,"IP",""

Here is the final /etc/chatscripts/aircel

# This chatfile was generated by pppconfig 2.3.18.
# Please do not delete any of the comments.  Pppconfig needs them.
# ispauth PAP
# abortstring
# modeminit
'' "ATZ"
'' "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0"
'' AT+CGDCONT=1,"IP",""
# ispnumber
OK-AT-OK "ATDT*99***1#"
# ispconnect
# prelogin

# ispname
# isppassword
# postlogin

# end of pppconfig stuff

And here is the final /etc/ppp/peers/aircel

# This optionfile was generated by pppconfig 2.3.18.
connect "/usr/sbin/chat -v -f /etc/chatscripts/aircel"
user "Aircel"
remotename aircel
ipparam aircel


Now, if you connected your mobile through wire, your mobile will be accessable through any one of /dev/ttyS* or /dev/ttyUSB* devices, you can start ‘pon aircel’ and get connected to net. But I’m going to setup bluetooth, so here is the steps,

root@Debian:/etc/ppp/peers# hcitool scan
root@Debian:/etc/ppp/peers# BDADDR="[type your mobile's bluetooth address here, it will be displayed as the output of above command]"
root@Debian:/etc/ppp/peers# hcitool cc "${BDADDR}"; hcitool auth "${BDADDR}"

Now, your authentication-agent will ask for pin and all, go through it and create a pair. Next step will be detecting the channel to setup a rfcomm bind,

root@Debian:/etc/ppp/peers# sdptool browse "${BDADDR}" | less

In the above command, there will be lot of services your mobile will provide to you, each will have seperate rec handle, name etc., some of them like obex push, obex file transfer, Headset Gateway, Phonebook access etc. You need to see ‘Dial-up Networking’ and note down the RFCOMM channel number. In my mobile, the RFCOMM channel number is ‘1’. So here is the step to bind your mobile’s RFCOMM channel with /dev/rfcomm0 device

root@Debian:/etc/ppp/peers# CHANNEL="[Type your mobile's Dial-up service's RFCOMM channel number]"
root@Debian:/etc/ppp/peers# rfcomm bind rfcomm0 "${BDADDR}" "${CHANNEL}"

‘bind’ will create a communication line between your mobile and /dev/rfcomm0 device. But it will not connect to your mobile until it is opened for reading/writing. You can check current rfcomm devices using following command

root@Debian:/etc/ppp/peers# rfcomm
rfcomm0: 3C:F7:2A:46:19:AB channel 1 clean

Now everything was setup, all you need to do is, type the following command

root@Debian:/etc/ppp/peers# pon aircel

it will start pppd and try to connect, but it will not throw any information in your terminal, you need to watch the activities through ‘tail -f /var/log/syslog’. If everything goes fine, it will establish ppp connection to Aircel. Here is the whole log

Mar 23 02:02:00 Debian bluetoothd[2072]: link_key_request (sba=00:1A:6B:E3:80:D8, dba=3C:F7:2A:46:19:AB)
Mar 23 02:02:01 Debian chat[31061]: abort on (BUSY)
Mar 23 02:02:01 Debian chat[31061]: abort on (NO CARRIER)
Mar 23 02:02:01 Debian chat[31061]: abort on (VOICE)
Mar 23 02:02:01 Debian chat[31061]: abort on (NO DIALTONE)
Mar 23 02:02:01 Debian chat[31061]: abort on (NO DIAL TONE)
Mar 23 02:02:01 Debian chat[31061]: abort on (NO ANSWER)
Mar 23 02:02:01 Debian chat[31061]: abort on (DELAYED)
Mar 23 02:02:01 Debian chat[31061]: send (ATZ^M)
Mar 23 02:02:01 Debian chat[31061]: send (ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0^M)
Mar 23 02:02:02 Debian chat[31061]: send (AT+CGDCONT=1,"IP",""^M)
Mar 23 02:02:02 Debian chat[31061]: expect (OK)
Mar 23 02:02:02 Debian chat[31061]: ATZ^M^M
Mar 23 02:02:02 Debian chat[31061]: OK
Mar 23 02:02:02 Debian chat[31061]:  -- got it
Mar 23 02:02:02 Debian chat[31061]: send (ATDT*99***1#^M)
Mar 23 02:02:02 Debian chat[31061]: expect (CONNECT)
Mar 23 02:02:02 Debian chat[31061]: ^M
Mar 23 02:02:02 Debian chat[31061]: ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0^M^M
Mar 23 02:02:02 Debian chat[31061]: OK^M
Mar 23 02:02:02 Debian chat[31061]: AT+CGDCONT=1,"IP",""^M^M
Mar 23 02:02:02 Debian chat[31061]: OK^M
Mar 23 02:02:04 Debian chat[31061]: ATDT*99***1#^M^M
Mar 23 02:02:04 Debian chat[31061]: CONNECT
Mar 23 02:02:04 Debian chat[31061]:  -- got it
Mar 23 02:02:04 Debian chat[31061]: send (\d)
Mar 23 02:02:05 Debian pppd[31042]: Serial connection established.
Mar 23 02:02:05 Debian pppd[31042]: using channel 9
Mar 23 02:02:05 Debian pppd[31042]: Using interface ppp0
Mar 23 02:02:05 Debian pppd[31042]: Connect: ppp0 <--> /dev/rfcomm0
Mar 23 02:02:05 Debian pppd[31042]: rcvd [LCP ConfReq id=0x0 <auth pap> <mru 1500> <asyncmap 0xa0000>]
Mar 23 02:02:05 Debian pppd[31042]: sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xcd88324c> <pcomp> <accomp>]
Mar 23 02:02:05 Debian pppd[31042]: sent [LCP ConfAck id=0x0 <auth pap> <mru 1500> <asyncmap 0xa0000>]
Mar 23 02:02:05 Debian pppd[31042]: rcvd [LCP ConfRej id=0x1 <magic 0xcd88324c> <pcomp> <accomp>]
Mar 23 02:02:05 Debian pppd[31042]: sent [LCP ConfReq id=0x2 <asyncmap 0x0>]
Mar 23 02:02:05 Debian pppd[31042]: rcvd [LCP ConfAck id=0x2 <asyncmap 0x0>]
Mar 23 02:02:05 Debian pppd[31042]: sent [LCP EchoReq id=0x0 magic=0x0]
Mar 23 02:02:05 Debian pppd[31042]: sent [PAP AuthReq id=0x1 user="Aircel" password=<hidden>]
Mar 23 02:02:05 Debian pppd[31042]: rcvd [LCP EchoRep id=0x0 magic=0x0]
Mar 23 02:02:05 Debian pppd[31042]: rcvd [PAP AuthAck id=0x1 ""]
Mar 23 02:02:05 Debian pppd[31042]: PAP authentication succeeded
Mar 23 02:02:05 Debian pppd[31042]: sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
Mar 23 02:02:05 Debian pppd[31042]: sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr> <ms-dns1> <ms-dns3>]
Mar 23 02:02:05 Debian pppd[31042]: rcvd [IPCP ConfReq id=0x0 <addr>]
Mar 23 02:02:05 Debian pppd[31042]: sent [IPCP ConfAck id=0x0 <addr>]
Mar 23 02:02:05 Debian pppd[31042]: rcvd [LCP ProtRej id=0x0 80 fd 01 01 00 0f 1a 04 78 00 18 04 78 00 15 03 2f]
Mar 23 02:02:05 Debian pppd[31042]: Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
Mar 23 02:02:06 Debian pppd[31042]: rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
Mar 23 02:02:06 Debian pppd[31042]: sent [IPCP ConfReq id=0x2 <addr> <ms-dns1> <ms-dns3>]
Mar 23 02:02:06 Debian pppd[31042]: rcvd [IPCP ConfNak id=0x2 <addr> <ms-dns1> <ms-dns3>]
Mar 23 02:02:06 Debian pppd[31042]: sent [IPCP ConfReq id=0x3 <addr> <ms-dns1> <ms-dns3>]
Mar 23 02:02:06 Debian pppd[31042]: rcvd [IPCP ConfAck id=0x3 <addr> <ms-dns1> <ms-dns3>]
Mar 23 02:02:06 Debian pppd[31042]: Cannot determine ethernet address for proxy ARP
Mar 23 02:02:06 Debian pppd[31042]: local  IP address
Mar 23 02:02:06 Debian pppd[31042]: remote IP address
Mar 23 02:02:06 Debian pppd[31042]: primary   DNS address
Mar 23 02:02:06 Debian pppd[31042]: secondary DNS address
Mar 23 02:02:06 Debian pppd[31042]: Script /etc/ppp/ip-up started (pid 31085)
Mar 23 02:02:07 Debian pppd[31042]: Script /etc/ppp/ip-up finished (pid 31085), status = 0x0
Mar 23 02:07:05 Debian pppd[31042]: Terminating on signal 15
Mar 23 02:07:05 Debian pppd[31042]: Connect time 5.0 minutes.
Mar 23 02:07:05 Debian pppd[31042]: Sent 70568 bytes, received 287622 bytes.
Mar 23 02:07:05 Debian pppd[31042]: Script /etc/ppp/ip-down started (pid 32324)
Mar 23 02:07:05 Debian pppd[31042]: sent [LCP TermReq id=0x3 "User request"]
Mar 23 02:07:05 Debian pppd[31042]: rcvd [LCP TermAck id=0x3]
Mar 23 02:07:05 Debian pppd[31042]: Connection terminated.
Mar 23 02:07:05 Debian pppd[31042]: Script /etc/ppp/ip-down finished (pid 32324), status = 0x0
Mar 23 02:07:05 Debian pppd[31042]: Exit.

To stop your pppd, type the following command

root@Debian:/etc/ppp/peers# poff aircel

Finally, once you finished with pppd, release the rfcomm0 bind using the following command,

root@Debian:/etc/ppp/peers# rfcomm release rfcomm0

Thats it. Enjoy old style ‘pppd’ :) Always old tech rules !!!

Functions from header files

Hi all,

I always think if we have a reference to all the C/C++ functions present in out system, it will be so much easier to write C programs with those functions. I posted this question to our ilugc, they introduced ‘ctags’ to me.

‘ctags’ is a simple utility which will produce a ‘ctags’ file which contains all definitions of macros, functions, structures, etc., If you want to know more about it, try ‘man ctags’.

The ‘ctags’ otuput file will be used by editors like vi, emacs to help developers to know about the syntex and function definiton.

I thought, It would be good if we can able to grep for functions, macros, from the ‘ctags’ file. Here is a simple script to achieve this task. Don’t forget to run,

$ ctags --verbose --recurse /usr/include

before executing this script. If you know better way to get reference to functions in our system, kindly share with me.

# Description:
# program to search for functions, macros, definiton, etc.,
# in a 'ctags' file.
# Author: Mohan Raman
# License: Its in public domain, use it whatever way you want

USAGE="[USAGE] [-n tagname]  [-t tagtype] [-f headerfilename]
		[-h help] ctagsfile1 [ctagsfile2 ...]
	-n tagname		tag name to search
	-f headerfilename	header file to search
	-t tagtype		tag type, anyone of listed below
				c	class
				d	defined macro
				e	enum/enum member
				f	function
				g	global
				m	member of struct/class/enum/union
				n	namespace
				s	struct
				t	typedef
				u	union
				v	global variable
	-h			print this help

while getopts "n:t:f:h" OPTIONS
	case "${OPTIONS}" in
	f) HEADER="${OPTARG}";;
	h) echo "${HELP}" && exit 0;;
	\?) echo "${USAGE}" && exit 1;;

shift $((OPTIND - 1))
test "${#}" -eq 0 && echo "${USAGE}" && exit 1

for FILE

	if test ! -z "${TAGNAME}"
			awk -F' ' "\\$1 ~ /${TAGNAME}/{print \\$0;}"`

	if test ! -z "${HEADER}"
			awk -F'	' "\\$2 ~ /${HEADER}/{print \\$0;}"`

	if test ! -z "${TAGTYPE}"
			grep ";\"	${TAGTYPE}"`

	echo "${OUTPUTBUFFER}" 

Download :

Mail with Attachments (Unix shellscript)

Hi friends,

Lot of us already know howto send attachments in mails using shellscript. Lot of us already wrote these kind of script. Here is one more script to do the same thing. I already added all the details in the script itself. It is self explainable. If somebody wants, take it.

# - script to send mail with multiple attachments.
# Wrote By: me! mohan43u.
# Date: Thu Mar 06 11:56:12 IST 2009
# License: Its in public domain. Use it whatever way you can.

USAGE="USAGE: [-t tolist] [-s subject] [-e encodetype] 
	-t tolist	comma seperated e-mail addresses
				(Default: current userid).

	-s subject	Subject line (Default: 'test mail from

	-e encodetype	Encoding type (x-uuencode/base64). only GNU uuencode
			can encode in base64. If you are using this script
			in Old school unixes(solaris, HP-UX, AIX, etc) use
			only 'x-uuencode'. Linux can handle both types
			(Default: x-uuencode).

	-h		Print this Help text

This script will read standard input as a mail body and takes filenames as 
arguments to generate a preformatted mail content in satndard output. you can
simply pipe the output to any MTA (sendmail, postfix etc.,) to send a mail
with attachments.

	$ -t -s 'mail with attachments' file1 \
		file2 | /usr/sbin/sendmail -v -i -t
	hi foo,
		I attached file1 and file2 with this mail. Take a look at it.


	This above command line will attach file1 and file2 and send a mail
	to The files file1 and file2 will be encoded in
	'x-uuencode' and attached with this mail.

SUBJECT="testmail from script"
BOUNDARY="`date +'%G%m%d%H%M%S'`"

while getopts 't:s:e:h' OPTIONS
	case "${OPTIONS}" in
	t) TO="${OPTARG}";; 
	h) echo "${HELP}" && exit 0;;
	\?) echo "${USAGE}" && exit 1;;

SHIFT_COUNT=`expr "${OPTIND}" - 1`
shift "${SHIFT_COUNT}"

	echo "To: ${TO}"
	echo "Subject: ${SUBJECT}"
	echo "Mime-Version: 1.0"
	echo "Content-Type: multipart/mixed; boundary=\"${BOUNDARY}\""
	echo "Content-Disposition: inline"
	echo "User-Agent: 0.1"
	BASENAME=`basename "${1}"`

	if test "${ENCODE_TYPE}" = "base64"
		ENCODED_MESSAGE=`uuencode -m "${FILE}" "${BASENAME}" \
		| egrep -v '^begin|^='`
		ENCODED_MESSAGE=`uuencode "${FILE}" "${BASENAME}"`

	echo "Content-Type: application/octet-stream"
	echo "Content-Disposition: attachment; filename=\"${BASENAME}\""
	echo "Content-Transfer-Encoding: ${ENCODE_TYPE}"
	echo "Content-type: text/plain; charset=utf-8"
	echo "Content-Disposition: inline"

# Main

echo "--${BOUNDARY}"
echo "${BODY}"
	echo "--${BOUNDARY}"
	create_octet_part "${FILENAME}"
echo "--${BOUNDARY}--"


Hi everyone,

Last week went with full of work pressure, No time to do anything for linux. With little time, I prepared for the FossConf 2009.

While preparing, I learnt a lot from gcc, autotools and lot others. Now I have some really good exposure about gcc and its tools. I feel very happy about going to madurai.

I already told to my PL about getting leave on friday, he also accepted it. I had some deep sleep on friday afternoon. Then I started my journey at 5pm. Exactly 8.05pm the bus started from Koyambedu Bus terminal.

On saturday morning 4am, I reached Trichy, then after 3 hours, I reached Maatuthavani Bus terminus in madurai. After some little journey in TownBus, I reached Thiyagaraja Engineering College, near Thiruparangundram, Madurai.

One of the student received me and gave me a seperate room. While going to the college, someone called me, What a surprise, Amachu standing near the Thiruparangundram bus stop, I went near to him, He asked about my journey and suggested me to call Bharathi and inform him.

Once I went into the room, I felt tired and sleepy, but somehow I was awaken and had a small trial on my presentation. Then it became boring, I started to look around the confrence.

Man!! lot of school students, participating and enjoying, Baskar(linuXpert) had full of attention towards those students. “I can even take these students if they don’t want to study Higher degrees, I can give the same salary a BE guy can get, to these students, b’se they worth equal”, he said to me.

Then I saw Amachu’s Ubuntu-tam stall, So I felt that I can be a part of Ubuntu-tam. I was a person after Amachu who is helping him a lot. I introduced myself to him, by surprise, he is padu, the same padmanaban from pollachi. After sometime, amachu went away from the stall, me and padu handled students and visitors to our stall. Sametime, padu shared his experience with me, and I shared my happiness with him. One great thing is, we both are Puppy Lovers.

The afternoon 2pm I started my session, I felt disappointed about the awareness of the students, especially BE students about gcc, and its tools. So I quickly finished my session and Bharathi took from where I finished.

We both finished the sessions. Amachu asked me to give company while returning to chennai. We both started Journy at 5pm. On the way we met lot of persons from “Yahoo!!, Kerala University, DrunkenMan etc”. We boarded SETC Airbus. The Bus started exactly 6.45pm from Maatudhavani Bus Terminus. While travelling, me and amachu exchanged our views about FOSS, Tamil Culture, Upper Middle Class, Respecting others culture, culture clashes in Metropolitan cities like mumbai, bangaluru. Amachu said that he also expects this kind of clash in Chennai.

At last, at 5.45am, we reached thambaram. All in all, this weekend was a meaningful to me. I met lot of FOSS enthusiasists and Also I teached something to the students.

After all the good things, I came to hear about NRCFOSS and their .ppt presentation. A lot of discussion going on in ILUGC mailing list.

In my openion, Whatever the reason is, if an organization is named for giving awareness about FOSS, then why the people working on NRCFOSS not using FOSS tools? How they will make awareness to others? And that person KG should change his attitude when posting in mailing list, his response to Arun SAG mail is not at all acceptable.

Anyway, here is my presentation. Hope this will help someone to program using C in Linux.


Hi everyone,

Here is another festivel in madurai, FOSSCONF2009 going to take place at madurai TEC(Thiagarajar Engineering College). Last year, It happened in MIT chennai. I also presented an introduction about my favourite puppylinux.

This year, I’m going to take C under Linux. Its about howto compile C programs under linux. What are the tools available under linux to create Softwares under linux. Why we need Autotools and lot more.

I think it will take atleast 2 hours to introduce C one more time to them, because at this time, they will be practicing some 4th gen language. Its a tough ask, lets hope students will understand my english.