≡ Menu


What Do You Use to Debug Linux / UNIX C/C++ Programs?

The purpose of a debugger is to allow you to see what is going on inside another program while it executes. It is useful to find out what another program was doing at the moment it crashed. I know most people will recommend GNU gdb, Nemiver, Valgrind or IDE such as Eclipse. I use gdb when it is really required; otherwise I debug the old fashioned way using printf() or cout statements.
[click to continue…]

Humor: On Feb, Friday 13, 2009 Unix time Will Be 1234567890

Unix time (POSIX time) is a system for describing points in time, defined as the number of seconds elapsed since midnight Coordinated Universal Time (UTC) of January 1, 1970, not counting leap seconds.
[click to continue…]

How To Write Object-Oriented Shell scripts For Multiple Platforms

This may come handy while writing cross-platform scripts.

If you don't want to commit to the idiosyncrasies of a specific shell running on a particular platform, try the Squirrel Shell. The Squirrel Shell provides an advanced, object-oriented scripting language that works equally well on UNIX, Linux, Mac OS X, and Windows systems. Write a script once, and run it anywhere.

Squirrel is a high level imperative/OO programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games.

=> Speaking UNIX: The Squirrel portable shell and scripting language

News Roundup: Dec., 15, 2008

Ubuntu has the strongest chance to take Linux mainstream
Interesting interview with Samba's Jeremy Allison - Samba project founder.

Comming soon: Wine 64 bit For 64 bit MS-Windows application
I can finally report success on the first ever win64 program running on wine. The program was a textbook classic, but to make it work gcc had to be changed a lot. This was done by Kai Tietz, who has put a lot of effort in the task of making gcc accept the calling convention.

Windows XP: The OS That Won't Quit
Dell announced it will offer systems with the aging Windows XP for a surcharge of US$150 over the newer Windows Vista--this only five months after it stopped offering XP on its Inspiron consumer desktop and laptop PCs. It is time to move on to Linux ;)

Culture and community go hand-in-hand with Perl programming
This time we chat with Larry Wall, creator of the Perl programming language and regarded as the father of modern scripting languages.

Linux scalability and performance notes from Facebook
Great talk! If you've read anything about scaling large websites, you've probably heard about memcached. memcached is a high-performance, distributed memory object caching system. Here at Facebook, we're likely the world's largest user of memcached.

How to sync Evolution with Google's PIM apps
While I'm a die-hard Google user -- especially the PIM apps -- I still appreciate offline applications for the integration with the desktop, speed, and features they sport. The Evolution contact and calendaring application is a great example: it's as feature-packed as Microsoft Outlook, but with GNOME integration, and it's fast. Gmail, by comparison, is slow and lacks any desktop integration. In a perfect world, Evolution would sync with Google's PIM apps. Unfortunately, there aren't any good, easy-to-use, comprehensive guides for setting up Evolution to sync with all of these apps -- until now.

WordPress Disable RSS Feed
Explains how to disable WordPress RSS / Atom / RSS2 feed url in 2 simple steps.

Competition Winner for Ubuntu Kung Fu Book

Last week I decided to run a little competition to see your tips related to UNIX and Linux. A massive thank you to all that have participated.

There were total 185 entries. Many entries were nice and I really enjoyed reading all of them. But, there can only be 3 winners (randomly selected):

=> slappinjohn
=> Hunter Perrin
=> Michael

There were many other great entries and I recommend you to check them out in the comments section.

Next month I will announce another small competition. If any one is interested sponsoring or would like give away as a prize in a competition, please contact me.

How To Use vi as Default Editor and Viewer in Midnight Commander

This is an user contributed article.

Midnight Commander (mc) is an user-friendly text-based file manager UI for Unix. Using mc, you can browse the filesystem easily and manipulate the files and directories quickly. You will not miss the standard command line prompt, which is also available within the mc itself. If you are new to mc, Midnight Commander (mc) Guide: Powerful Text based File Manager for Unix article will give you a quick jumpstart. In this article, let us review how to solve couple of common annoyance about viewing a file in mc.

Use vi as default editor and viewer in mc

Mc uses mcedit for file editor and mcview for file viewer. Like most of you, I'm very comfortable with vi and would like to use vi for both viewing and editing than the mc's internal editor and viewer.

Launch mc in color mode by typing “mc -c” from the command line. Press F9 (or Esc followed by 9) to activate the top menu → select Options menu → select Configurations menu-item, which will display “Configure Options” dialog → de-select the check-box next to “Use Internal Edit” and “Use Internal View”, as shown below to disable, internal editor and viewer.

After this change, when you select a file and press Esc 3 to view or Esc 4 to edit, mc will use vi.

Fig.01 Mc configure options to disable internal editor and viewer

Fig.01 Mc configure options to disable internal editor and viewer

Change the Enter key behavior to view file using vi instead of executing it.

When you select a shell script and press enter, mc will execute it by default. Also, by default when you press enter on text files, nothing happens. I prefer to view the shell script when I press enter key. Also, I would like to view the text file using vi when I press enter key. You can achieve this by modifying the mc extension file as shown below.

Press F9 (or Esc followed by 9) to active the top menu. From command menu → select “Edit extension file” men-item → This will display the extension file. Go to the bottom of the extension file and change the value of open and view parameter values as shown below.

# Default target for anything not described above default/*

        Open=%var{EDITOR:vi} %f
        View=%var{EDITOR:vi} %f 

After the above change, when you press enter key on a shell script, it will open it in vi instead of executing it. This will also open text files in vi when you press enter after selecting it.

Lighttpd: Enable IPv6 Support

Lighttpd supports both IPv6 and IPv4 protocol out of box. You need to compile lighttpd with IPv6 support. The server.use-ipv6 option bind to the IPv6 socket. You need to bind to both IPv6 and IPv4 using the following syntax.

First, see compile-time features (find out if IPv6 is enabled or not), enter:
# lighttpd -V
Sample output:

Build-Date: Sep 30 2008 06:18:08
Event Handlers:
	+ select (generic)
	+ poll (Unix)
	+ rt-signals (Linux 2.4+)
	+ epoll (Linux 2.6)
	- /dev/poll (Solaris)
	- kqueue (FreeBSD)
Network handler:
	+ sendfile
	+ IPv6 support
	+ zlib support
	+ bzip2 support
	+ crypt support
	+ SSL Support
	+ PCRE support
	- mySQL support
	- LDAP support
	- memcached support
	- FAM support
	- LUA support
	- xml support
	- SQLite support
	- GDBM support

You must see + IPv6 support enabled. If not recompile lighttpd with IPv6 support. Once compiled open lighttpd.conf file:
# vi lighttpd.conf
To enable IPV6 and IPV4 together, enter:

server.use-ipv6 = "enable"
server.port = 80
$SERVER["socket"] == "" {
# add your stuff

Save and close the file. Restart lighttpd:
# service lighttpd restart

Above config is only useful if you want to use all available IPv4 and IPv6 address. Following configuration will bind IPv4 to and IPv6 to address:
Open lighttpd.conf setup main server IP address as follows:

server.port = 80 
server.bind = ""

Below that add IPv6 config as follows:

$SERVER["socket"] == "[2001:470:1f04:55a::2]:80" {
   # ...
   # your rest of config for ipv6 host
   # ...

Here is my sample config file with IPv4 and IPv6 dual stack enabled:

server.modules              = (
server.errorlog            = "/var/log/lighttpd/error.log"
accesslog.filename         = "/var/log/lighttpd/access.log"
index-file.names            = ( "index.php", "index.html", "index.htm", "default.htm" )
server.tag                 = "lighttpd"
# FastCGI php5
fastcgi.map-extensions = ( ".html" => ".php" )
fastcgi.server    = ( ".php" =>
                "bin-path" => "/usr/bin/php-cgi",
                "socket" => "/tmp/php-cgi.socket",
                "max-procs" => 4,
                "idle-timeout" => 30,
                "bin-environment" => (
                        "PHP_FCGI_CHILDREN" => "10",
                        "PHP_FCGI_MAX_REQUESTS" => "20000"
                "bin-copy-environment" => (
                        "PATH", "SHELL", "USER"
                "broken-scriptfilename" => "enable"
include "mimetype.conf"
server.document-root = "/home/lighttpd/example.com/http"
server.pid-file = "/var/run/lighttpd.pid"
server.username = "lighttpd"
server.groupname = "lighttpd"
# Turn on IPv4 config
server.port = 80 
server.bind = ""
server.error-handler-404 = "/index.php?error=404"
### IPv6 Config ###
# Note only log file name changed
$SERVER["socket"] == "[2607:f0d0:1002:11::5]:80" {
	accesslog.filename         = "/var/log/lighttpd/ipv6.access.log"
	server.document-root = "/home/lighttpd/example.com/http"
	server.error-handler-404 = "/index.php?error=404"