Category Archives: GNU/Linux

Changing Caps_Lock as third Ctrl key

  • create map
  • $ sudo dumpkeys | head -1 > /usr/share/keymaps/Caps2Ctrl.map

  • add following lines to that file
  • keycode 58 = Control # This makes Caps act as Ctrl
    # keycode 29 = Caps_Lock # This makes Ctrl act as Caps
    # alt_is_meta # This fixes the Alt key

  • run loadkeys on that file
  • $ sudo loadkeys /usr/share/keymaps/Caps2Ctrl.map

  • to revert and load default keymap
  • $ sudo loadkeys -d

    Reference : http://www.emacswiki.org/emacs/MovingTheCtrlKey#toc6

    Another option is to execute following command

    $ setxkbmap -option ctrl:nocaps

    Advertisements

    tmux – terminal multiplexer – an alternative for screen

    I really admire OpenBSD projects. “tmux” aka Terminal Multiplexer is one of them.
    Today Vedang Manerikar, my co-worker told me that he uses “tmux” rather than “GNU Screen”. So I decided to try “tmux” and after some googling I found that GNU Screen development has stopped 2 years back and it’s almost a dead project. Whereas “tmux” is actively developed by OpenBSD community. I just spent around 1.5 hours learning the common key-bindings of “tmux”. My 1.5 hours experience says “tmux” is better than “screen”.

    The first feature I liked is windows numbering. 1-9 and then it starts with a-z. OTOH “screen” numbers windows from 0-n where n is a number. This way you can not access windows with 10 and onwards easily. But in “tmux” you can as after 9 “tmux” uses alphabets to name windows.

    The second feature is “automatically window renaming depending on command” … this is handy where you don’t have to everytime rename a window and saves time.

    That’s the quick observation. Will post other interesting features as I find them.

    easily creating name based virtual hosts in apache

    Check if your /etc/apache2/ports.conf has following two lines

    NameVirtualHost *:80
    Listen 80

    Create two directories in /var/www
    # mkdir /var/www/{foo,bar}

    These two directories in /var/www/ will serve as a document root for our two test sites foo.com and bar.com respectively

    Create index.html file in each of these two directories and put some html code in it.
    e.g.
    I am foo.com
    I am bar.com

    Put entries in /etc/hosts
    You need to also put 2 entries in your /etc/hosts file since we are testing it on localhost. If you are doing it on a server then make sure you have respective A records in DNS.
    Open /etc/hosts in your favourite editor and put following two entries at the bottom of the file without disturbing original contents of file

    127.0.0.4 foo.com foo
    127.0.0.5 bar.com bar

    Just make sure that above IPs are not already in use in same file …if any of them is in use, then for your entries you can
    use any IP in 127.x.x.x range.

    Create virtual hosts
    Now create two files, “foo.com” and “bar.com” in /etc/apache2/sites-available/
    Contents of foo.com

    ServerName foo.com
    ServerAlias http://www.foo.com
    DocumentRoot /var/www/foo/


    Similarly create bar.com with following content


    ServerName bar.com
    ServerAlias http://www.bar.com
    DocumentRoot /var/www/bar/

    Enable newly created sites
    # a2ensite foo.com bar.com

    Reload Apache
    # service apache2 reload OR # /etc/init.d/apache2 reload

    Open your browser and put “foo.com” in address bar .. you should be able to see the contents of /var/www/foo/index.html file
    Repeat same step for “bar.com” as well to confirm that your setup is working

    Enjoy!!

    ktorrent country flags

    How to get country flags in Ktorrent

    I love to see country flags in Ktorrents peers tab. Though the database is not much accurate, the flags look nice. 🙂

    I upgraded the KDE few months back and came to know that flags are no more shown in Ktorrent. After some googling I found that one should have `kdebase-data` and `libgeoip1` packages installed. Also in Ktorrent ,`infowidget` plugin should be active.

    I had both packages already installed and the plugin was also enabled, but still flags were not visible.

    The reason behind this is mentioned in README.Debian provided with KTorrent package. So after reading it, I read README.Debian for libgeoip1 package and solved the problem. 🙂 Enjoy.

    Install libgeoip1 package
    # aptitude install libgeoip1

    Create a directory
    # mkdir /usr/share/GeoIP/

    Run script provided with libgeoip1 package
    # cd /usr/share/doc/libgeoip1/examples/
    # ./geolitecountryv4.sh
    # ./geolitecountryv6.sh

    DONE!!!

    IBus – now write in your mother tongue – मातृभाषेत लिहा

    I love to write in my mother tongue Marathi. For last four years I was using a
    wonderful package SCIM for it. But yesterday I upgraded to Kubuntu 10.10 and
    found Skim crashing upon start. So decided to ditch it in favour of IBus since
    SCIM is not actively developed. Here’s a small howto for getting IBus running
    on Kubuntu.

    How to configure IBus in Kubuntu 10.10 aka Maverick Meerkat

    First install IBus

    $ sudo aptitude install ibus ibus-qt4 ibus-gtk ibus-m17n

    Now switch input method (don’t use sudo here)

    $ im-switch -s ibus

    This will create a symlink in $HOME/.xinput.d/ directory.

    If you already have symlink in $HOME/.xinput.d/ pointing to a file other than
    ibus in /etc/X11/xinit/xinput.d/ directory then remove that symlink. Else the
    above command will say File Exists and won’t create a new symlink.

    Start IBus setup

    Press Alt+F2 and type ibus-setup and press Enter

    You will get a IBus Preferences window.

    In General tab click Show icon on system tray

    In Input Method tab select an input method of your choice and click Add button.

    The first method in the list will be your default input method.

    Adjust other options to suit to your own choice and close the window.

    Starting IBus on KDE Startup

    Go to
    KMenu -> Applications -> Settings -> System Settings -> System Administration
    -> Starup and Shutdown -> Add Program

    Then put /usr/bin/ibus-daemon in Text Box and click OK. Now you will get a
    Properties Dialog Box.

    In that, click on Application tab and put
    Name – ibus-daemon
    Description – Intelligent Input Bus
    Command – /usr/bin/ibus-daemon –desktop=kde –panel=/usr/lib/ibus/ibus-ui-kde
    Click OK.

    Now Logout of KDE and Login again.

    Open text editor and press Control + Space and you should be able to write
    in the language you chose as default input method.

    EDIT: Additionally, you can export following variables in your ~/.bashrc

    export GTK_IM_MODULE=ibus
    export QT_IM_MODULE=ibus
    export XMODIFIERS=”@im=ibus”

    i want more space…

    The default Debian installation puts lots of documentation with various locale on /usr. These files are not used most of the time but end up eating lot of disk space.

    Debian provides localepurge and deborphan to remove unwanted files from hard disk and to retain disk space.

    Installation
    # aptitude install localepurge deborphan

    Configuration of localepurge
    # dpkg-reconfigure localepurge

    Cleanup disk space
    # localepurge

    Following command finds unwanted and independent packages, which are no longer required and removes them
    # deborphan

    When packages are installed using online Debian repository, APT downloads them and stores all .deb files in /var/cache/apt/archives/. After the installation, generally these files are no more required. Following command cleans up these unwanted files and reclaims disk space.
    # aptitude clean

    be on time my friends… with ntp

    It’s very important to keep your system clock aligned to the exact timezone you reside. Following commands help to keep it in sync.

    First select appropriate timezone
    # dpkg-reconfigure tzdata

    Above command actually copies your zoneinfo file from /usr/share/zoneinfo/ to /etc/localtime
    So you can manually copy the file from zoneinfo directory to /etc/localtime on non-debian systems.

    Now install following package to sync your system clock with Time Servers using Network Time Protocol (NTP)

    # aptitude install ntpdate
    # aptitude install openntpd

    The ntpdate OpenNTPD keeps on checking time periodically to keep system time in sync with time servers.

    OpenNTPD is a secure NTP daemon developed by OpenBSD Developers. (Theo de Raadt you r0ck ;))
    You can also install ntp – a local ntp daemon as an alternative to OpenNTPD.

    Thanks poisonbit for pointing out that ntpdate is now unmaintained and NTP or OpenNTPD is preferred over it. Check out first comment.