Paul - The Programmer

simple & stupid

Change the Gnome Commander default editor

The default editor for Gnome Commander is geit. Of cause gedit is good enough, but I prefer to VIM.

The changing of preferred programs in Gnome Commander seems broken somehow. It simply does not work.

Since Gnome is following the standard of handling mime types, we can still update the mime settings to choose the preferred editor.

The preferred applicaiton configuration file is located in ~/.local/share/applications, the file name is defaults.list.

Here is the content of my default.list

[Default Applications]
text/html=gvim.desktop
application/xml=gvim.desktop
text/plain=gvim.desktop
text/x-java=gvim.desktop
text/x-python=gvim.desktop

As you may guess, I open all the html, xml, text, java and python file with GVIM.

The gvim.desktop is the configuration for gvim for what mime types it can handle and its launching command.

Good Linux tool, netcat

Netcat, as know as nc, is a simple command line tool to send and receive data with TCP or UDP protocal.

There are many tutorials for the netact on the internet, since it has been wildly used as a back-end tool to :

  • Simulate server
  • Scanning ports
  • File transfers
  • Proxy gateway
  • Many other things to transfer data with TCP/UDP from one place to another.

Hence here I'd like to show you something different, an example of how to create a echo server with netcat.

The server side just as simple as one line command:

$ nc -l -p 12345 -c 'while true; do read i && echo [echo] $i; done'

Then the telnet can be used as a client to connect to the nc server

$ telnet localhost 12345
hello
[echo] hello

Once you input any string, the server returns your input with [echo] prefix.

Good Linux tool, Module Assistant

Module Assistant is a powerful tool to build Debian kernel modules without re-compile the whole linux kernel. Module Assitant extramly facilitate the process of building kenerl modules by automatically download the module source code from Debian package repository and compile the source code to generate kernel module binary file. 

Moduel Assistant requires to run as root. With Module Assistant, the process of building kernel module is simplyfied to 5 steps.

- Install Module Assistant, 

$ sudo apt-get install module-assistant

- Prepare the artifact for building kernel modules,

$ sudo m-a prepare

The command will automatically download and install the kernel headers corresponding to current kernel and needed building tools like gcc, make and so on.

- Update the module assitant suppored module list,

$ sudo m-a update

-  Check supported module list,

$ sudo m-a list

- Build the needed module, such as, the module for Logitech Quickcam,

$ sudo m-a a-i qc-usb-source

Option a-i stands for automatic installation.

Good Linux tool, Network Manager.

Network Manager is a GUI application powered by dbus for network configuration. Network Manager provides a user-friendly interface to set up the wired and wireless network interface.

Network Manager consists of a background daemon process running as root and a front-end applet application.

Install Network Manager with command,

$ sudo apt-get install network-manager network-manager-gnome

To utilize the Network Manager, for Debian users, the user has to be a member of netdev group. For other distribution users, the similar user privileges are required.

$ sudo usermod -a -G netdev paul

Verify the user group setting with

$ id paul
uid=1000(paul) gid=1000(paul) groups=1000(paul),4(adm),24(cdrom),25(floppy),29(audio),44(video),46(plugdev),109(netdev),110(bluetooth),116(scanner)

By default, Network Manager only handles the interface not declared in /etc/network/interfaces.

Not declared interface means the interface is not described in the interface or the interface is disableed with a #NetworkMangaer# prefix.

For instance,

# The primary network interface
allow-hotplug eth0
#NetworkManager#iface eth0 inet dhcp

To enable Network Manager to handle the interfaces in /etc/network/interfaces, the Network Manager's configuration file /etc/NetworkManager/NetworkManager.conf should be updated as:

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=true

Then restart network-manager service:

$ sudo /etc/init.d/network-manager restart

 

Replace scim with ibus on Debian

The default input method framework of Debian is scim.

You may know from my last post that I just change to use sunpinyin for my default Chinese input method. But the scim sunpinyin engine seems like a little buggy. I can not switch between English and Chinese input by the shift. The window may hangs when I am typing pinyin.

Okay. I change to use ibus as well.

Firstly, the scim should be remove completely from system. Use the Synaptic or apt-get to remove all the scim related package ( scim,  scim input engines, scim libs and so on ).

$ sudo apt-get purge scim

Secondary, install the ibus and ibus sunpinyin engine.

$ sudo apt-get install ibus
$ sudo apt-get -t experimental ibus-sunpinyin

Finally, set ibus the default input method then restart the X session to active the ibus input method.

$ im-switch -s ibus