Showing posts with label sysadmin. Show all posts
Showing posts with label sysadmin. Show all posts

Wednesday, August 29, 2012

Pound sterling and Euro sign and Indian Rupee symbol on a UK keyboard

Well,
         I am in UK right now and I am going to be here for quite some time. One thing annoying about being in UK is UK keyboard. Especially once you have a habit of using a US keyboard. Thankfully, I have brought my ergonomic US keyboard with me over here. But then the trouble is what do you do if you want to type £ ? If you are a linux person like me, this is what you should do.

Create a file named .Xmodmap in your $HOME.
Put the followings in the file


add mod3        =       Mode_switch
keysym  Alt_R   =       Mode_switch
keycode 26 = E NoSymbol EuroSign cent
keycode 46 = L NoSymbol sterling cent
keycode 27 = R NoSymbol U20b9 NoSymbol

What it does is that it assigns ALT_R (Right Alt)+e to €, ALT_R+SHIFT+e to ¢, ALT_R+l to £, ALT_R+SHIFT+l to ¢ and ALT_R+r to ₹. For more details refer to 'man xmodmap'.

Now, either you logout and log back in or run

 xmodmap ~/.Xmodmap

and Voila!! You have pound sterling , euro, cent sign and Indian rupee symbols available at your finger tips!! Literally!!


Saturday, June 18, 2011

Turning your laptop into a wifi router

Well,
     It's been a long time since I have posted anything in english. Anyways, let me get to the point real quickly. I have two laptops and one wired connection through which I connect to the internet. So yesterday I turned one of my laptop into a wifi router and got both the laptops connected to internet.

If you search on google regarding 'turning your laptop into access point/router' you will find many ways to do it. Most of it describes it how to do it using command lines. Though, personally I am a big fan of command line, NetworkManager that comes with many linux distros makes it real easy.

What you do is the following. You can choose one laptop to be the mater ( which is going to be turned into a wifi router ) and another slave. At least these are the names I am going to use.

Connect the master to the wired network. I am assuming that you know how to get wired network working on your linux box. Once you have done this, it is really a piece of cake.


In master, click on NetworkManager symbol/applet ( usually sitting in the top-right corner ) and click on "Create New wireless network..". Choose an SSID(name) say "mynetwork". Choose a security mechanism ( say WEP 128bit ) and type in your key. You need to remember this key. That's it, your laptop is turned into a wifi router.

Now on the slave, it should show the wifi connection available by name "mynetwork". If it does not, go to nm ( NetworkManager) and go to "Connect to hidden  wireless network.." and provide the name "mynetwork" and the key that you have entered for the network. You should be good to go now.

What happens behind the scene is as follows. Master acts as a bootstrap server, dns server, gateway for the client. Hence, providing the client with an IP address and masquerading it to provide it connection to the outside world. Enables packet forwarding in the kernel ( "cat /proc/sys/net/ipv4/ip_forward" should show "1"). Checkout "sudo iptables -vL" and "sudo iptables -vL -t nat" in the master for more details. It provides dns service to the client through multicast dns without having to run a full fledged dns server. Routes are added into the routing table ( "sudo route") appropriately.

It does not matter if you do not understand the paragraph above. The good thing is that it has been made piece of cake for normal users and probably requires less amount of efforts than doing the same thing in windows.

Thing to note that you can connect multiple slaves to this masters. However, you may not get as good performance as a dedicated hardware router.

Happy networking!! :-)









Friday, October 01, 2010

Vim Trick : Search and Replace

Today I found out a cool vim trick. Not so much great, but sure it's nice to know.

For example, if you want to search for string consisting of all a's followed by all b's and then reverse it.


aaaaaabbb -> bbbaaaaaa

:s/\(a+\)\(b+\)/\=submatch(2).submatch(1)/

\(regexp\) defines an atom in vim. So the first atom is defined as a* and the second is defined as b*. In the replace pattern we are executing a vim expression. submatch(0) stands for the entire matched pattern where as submatch(1), submatch(2) stands for the strings matched by first atom, second atom etc.

So the above vim command reverses the order of a's and b's. Having a vim expression as a replace pattern gives enormous power and can be used for much more complex things :-)

Monday, August 30, 2010

Download Lyrics from Rankaar

Dear Friends,
Many of you would like to get lyrics from Rankaar for your personal use. To save you the trouble of writing them down on pen and paper here is the trick you can use :
  1. From any browser, load the page containing your favourite song.
  2. Click on 'Email This Post'  to email it to yourself. Then you can copy it from your email account. Alternatively, you can do the following
  3. Go to File -> Save As. Now, give it any name you want the file to be saved as. For example save it as 'mysong.htm' or 'mysong.html'.
  4. Now, from your computer, open this file 'mysong.htm' or 'mysong.html' using Microsoft Word. You will see that now you can select the lyrics of the songs.
  5. Alternatively, open this file 'mysong.htm' or 'mysong.html' in WordPad or NotePad.
  6. Now, go to Edit-> Replace. Search for 'return false' ( without the single quotes, of course! ) and replace it with 'return true'. Save it and close it.
  7. Now, double click on 'mysong.htm', it will open in your browser. But now, you will see that you will be able to select the lyrics/text of your choice.
Contents on Rankaar as under Creative Commons License. Hence, you are free to use it for any non-commercial purpose and you do not plagiarize (look it up in a dictionary :-) ).

--Saurabh Joshi

Rankaar Songs Download

Dear Friends,
Rankaar has stopped support of Firefox browser. Here is a fix for you so that you can continue enjoying your favourite Gujarati music.

  1. Install Firefox.
  2. Install "User Agent Switcher" add-on to Firefox. You can install it via the link provided, or go to Tools -> Add-ons -> Get Add-ons and search for "User Agent Switcher" and install it.
  3. Restart Firefox
  4. Go to Tools -> Default User Agent -> Internet Explorer -> Internet Explorer 8 ( you can choose 6 or 7 too )
  5. What this add-on does is that it sends the signature of IE 8 to the website to make it believe that you are connecting to the site using IE 8, even though you are using Firefox.
  6. Now you can open Rankaar from Firefox.
Note : please note that, having one browser pretending to be another browser will not give you a good user experience, as the pages might not render as they should. Hence, you should use it only to surf websites which requires that you use Internet Explorer only. After that, you should switch it back to default mode using , Tools -> Internet Explorer -> Default User Agent.

Thursday, August 26, 2010

ગુજરાતી સંગીત નો લ્હાવો - Enjoy Gujarati Music

Dear Friends,
                     Due to some people with selfish and evil intentions I am removing this post. Those who host their website under 'Creative Commons Licence' should really know the true meaning of it. Creative Commons Licence allows one to use and copy any material for non-commercial use in its original form ( non-derivative ) as long as the due credits are given to original authors ( no plagiarisms ).

Bunch of selfish and self proclaimed gujarati fans just want to increase the hits on their website and want to keep other fellow gujaratis begging. To satisfy their ulterior ego they forced me to remove a post which stated how can one use Firefox and its add-ons to enjoy gujarati music for personal pleasure.


It is worth noting that Firefox ( browser ) and its add-ons like Greasemonkey ( allows to customize look of a page ), Flashgot ( allows downloading of any flash based material ) and User agent switcher ( allows to switch user-agent ) are all in open source domain available for free.

Sunday, February 21, 2010

Screen capture utility

I was looking for a utility that can capture screen session in linux. Finally, I found it!

http://recordmydesktop.sourceforge.net/

Tuesday, November 04, 2008

How to : QEMU networking

Hi All,
It has been ages since I have written anything over here. One of the main reason is that I have started posting mathematical post at my wordpress blog.

Anyways, Sameer and I were trying to get our hands dirty on Qemu networking. Although there is a fairly good description is given over here, I am trying to fill in here a few missing bits.

Okay, so here is the scenario we want to create.

On one machine ( say host-A ) we want to create many guest machines ( guestA1, guestA2 ) etc. Similarly, there is another machine ( host-B ) having many guest machines ( guestB1, guestB2 ). We want to make guestA* communicate with guestB*.

I am assuming that readers are aware of how to install a guest OS on a guest machine created by qemu.

First we need to configure a ipv4-over-ipv4 tunnel for the host machines.

--host-A configuration is as follows

ip : 172.27.16.1
netmask : 255.255.255.0
default gateway : 172.27.16.254

host-B configuration is
ip : 172.27.16.2

netmask and gateway is the same as above.

--In host-A ( as root ) do the following

root@hostA# ip tunnel add tunl1 mode ipip remote 172.27.16.2 dev eth0

-- this command essentially create one endpoint of the tunnel in host-A. It says that the other end of the tunnel lies at ip 172.27.16.2. Also, the tunnel device will use eth0 as its physical device.

root@hostA# ip link set tunl1 up

-- this command will bring up the tunnel interface

root@hostA#ifconfig tunl1 10.0.1.1 pointopoint 172.27.16.2

-- guestA network will be 10.0.1.0/24 network and tunnel device should be a part of it. This command gives the tunnel device an ip address and it says that other endpoint of the tunnel will be at 172.27.16.2

root@hostA# route

--this will show you the current configuration of routing table. There might be an entry in the routing table

172.27.16.2 * 255.255.255.255 U 0 0 tunl1

--you need to delete this entry using following command :

root@hostA# route del -net 172.27.16.2 netmask 255.255.255.255 dev tunl1

--Also you need to tell routing table that guestB network ( 10.0.2.0/24) should be routed through the tunnel

root@hostA# route add -net 10.0.2.0 netmask 255.255.255.0 dev tunl1

--You need to repeat the same procedure for hostB with suitable ips ( use 10.0.1.* instead of 10.0.2.* and vice versa , replace 172.27.16.1 with 172.27.16.2 and vice versa )

--By now, your tunnel should be working. To check, try

root@hostA# ping 10.0.2.1

root@hostB# ping 10.0.1.1

--If it does not ping, it might be the case that your firewall is coming into the way. If you are expert enough, modify your firewall rules with iptables. If not, lets first save your firewall rules

root@hostA# iptables-save | cat > iptablebackup.bak

--flush the firewall rules now

root@hostA# iptables -F
root@hostA# iptables -t nat -F

--Now, that firewall is completely disabled, the tunnel should work. (Of course, you need to disable your firewall at hostB as well! ) If it still does not work, then there might be some other problem or you might not have done things right.

-- you can restore your firewall ( later ) with

root@hostA# cat iptablebackup.bak | iptables-restore

--Okay, so the tunnel is working now!! Great news!! But what next??
Next we create a tapping device - a virtual network interface - which will be visible to the guest OSes.

root@hostA# tunctl -u username

-- provide a username here. This user will be able to use this tapping device while initializing qemu process. This command would have created a tapping device (tap0) in your system

--assign an ip address of guestA network to tapping device

root@hostA# ip addr add 10.0.1.2 dev tap0

-- bring the tapping device up

root@hostA# ip link set tap0 up

-- Also create a file /etc/qemu-ifup which can look like following :
#!/bin/bash
#echo "bringing up interface $1"

-- Now start the first guestOS

username@hostA$ qemu -net nic,macaddr=macaddr1 -net tap,ifname=tap0 -net socket,mcast=230.0.0.1:9999 ....

--second guestOS can be started with following
username@hostA$ qemu -net nic,macaddr=macaddr2 -net socket, mcast=230.0.0.1:9999 ...

-- multicast socket is needed for mchines in guestA network to talk to each other

--In the guestA1 do the following :

root@guestA1# ifconfig eth0 10.0.1.3 netmask 255.255.255.0
root@guestA1# route add default gw 10.0.1.2 dev eth0

-- Note that we have given the ip address of tapping device as the gateway fo guest OSes
-- second, third etc guest machines can be configured with different ip addresses for their eth0

-- Repeat this procedure on host-B as well with appropriate ip addresses.

-- Now, you should be able to ping machines from guestA network to guestB network and vice versa. However, this does not yet allow you to connect to host network. To do that, you need to enable ip forwardng

root@hostA# echo "1" > /proc/sys/net/ipv4/ip_forward

-- perform source NAT

root@hostA# iptables -t nat -I POSTROUTING 1 -o eth0 -j SNAT --to-source 172.27.16.1

--Now, from guestA network ( 10.0.1.0/24 ) you should be able to connect to ( 10.0.2.0/24 ) as well as host network ( 172.27.16.0/24 )

-- To delete the tunnel

root@hostA# ip link set tunl1 down
root@hostA# ip tunnel del tunl1

--To delte the tapping device

root@hostA# tunctl -d tap0

--Above mentioned setup is tested with host machines running fedora core 9 and guest machines running Arch Linux, Debian etc.

If you have any queries post it as comments, I will be willing to answer if I can.