Category: Unix

Chm viewer on Ubuntun

Posted by – September 1, 2010

xchm: Compiled HTML Help (CHM) file viewer for X
To get it:
sudo apt-get install xchm

To search chm relates info:
sudo aptitude search chm

Adding run-time dependency on Ubuntu

Posted by – August 5, 2010

This patch adds a runtime dependency on “dbus-1-utils” to the original source deb.

Refers to:

diff -u avahi-0.5.2/debian/control avahi-0.5.2/debian/control
— avahi-0.5.2/debian/control
+++ avahi-0.5.2/debian/control
@@ -7,7 +7,7 @@

Package: avahi-daemon
Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, adduser
+Depends: ${shlibs:Depends}, ${misc:Depends}, adduser, dbus-1-utils
Recommends: dbus, libnss-mdns
Suggests: avahi-dnsconfd
Conflicts: mdnsresponder
diff -u avahi-0.5.2/debian/changelog avahi-0.5.2/debian/changelog
— avahi-0.5.2/debian/changelog
+++ avahi-0.5.2/debian/changelog
@@ -1,3 +1,9 @@
+avahi (0.5.2-2) experimental; urgency=low
+  * Added dependency on dbus-1-utils, required by postinst
+ — Lorenzo J. Lucchini <>  Wed, 15 Feb 2006 02:39:05 +0100
avahi (0.5.2-1) experimental; urgency=low

* New upstream release.

design: sign a Debian changes and dsc file pair using GPG/PGP

Posted by – August 1, 2010

On Ubuntu there are at least two methods to sign a debian changes & dsc file pair using PGP:
Enter into source codes dir, and type below each one commands:
1.sudo dpkg-buildpackage -sa -k$GPG_KEY

note: sign the pair during building package.

2. Two steps below:
1). sudo dpkg-buildpackage -sa
2). sudo debsign -k$GPG_KEY *.changes

note: sign the pair AFTER build package.

ssh: 关闭ssh连接时的yes|no提示

Posted by – June 2, 2010

ssh: Disable asking yes/no when first time using ssh to connect a host.

j@ju10:~$ cat > ~/.ssh/config << end
UserKnownHostsFile /dev/null
ConnectTimeout 15
PasswordAuthentication no
StrictHostKeyChecking no
j@ju10:~$ more ~/.ssh/config
UserKnownHostsFile /dev/null
ConnectTimeout 15
PasswordAuthentication no
StrictHostKeyChecking no

j@ju10:~$ cat > ~/.ssh/config << endUserKnownHostsFile /dev/nullConnectTimeout 15PasswordAuthentication noStrictHostKeyChecking noendjin@jin-u10:~$ more ~/.ssh/config UserKnownHostsFile /dev/nullConnectTimeout 15PasswordAuthentication noStrictHostKeyChecking no


ssh -o StrictHostKeyChecking=”no” root@ipAddress

Gnome Nanny, a Parental Control System for Linux

Posted by – May 25, 2010

Gnome Nanny, a Parental Control System for Linux

Refers to:

nanny logo

I am not in favour of monitored or filtered Internet at all. I love Internet the way it is and I hate if someone tries to censor it. But we have to admit that there is a lot of bad stuff on the Internet that you definitely don’t want little kids to come across. Gnome Nanny is a parental control system build for this purpose. Not just the websites, it can also be used to monitor and control the time spent on web or chatting.


  • You can easily control what the kids/users are doing on the computer.
  • How long a user can be using the compuer, browse the web, email and instant message.
  • You can decide the time of the day you want them to do these things.
  • You can even filter out the web pages seen by each of the user by blocking undesirable websites.
  • Its really easy to understand and configure.

The most recent version of Nanny available is 2.29.2. No stable version has been released yet.

Download and Install the Latest version of Nanny in Ubuntu

In order to install the latest development release in Ubuntu, you will have to install it using the ppa. You can find the PPA archive of Nanny here. Follow the instruction in this howto to install nanny in Ubuntu from the PPA. In case of any trouble, leave a comment.

Other distro users may install the source packages from their download page and give it a try.

After installation you can find it at System -> Administration -> Parental Control.

How to Configure Nanny

Understanding the working of Nanny is really easy. Its developers have worked pretty well to improve its usability. In the first glance, you will easily understand how to use it. You can find it in System -> Administration -> Parental control.

With these bars(click them), you can select which part of the day you want a particular service to be active. Different services are mentioned in separate tabs. Just check the option above to activate any option.

Nanny’s Web Content Filtering System

If you want to control the websites that can be accessed you can easily do that by maintaining lists of allowed and blocked sites. Check the enable web filtering box in the web browser tab and click configure.

You can even download the list of blacklisted websites from internet and ofcouse manual addition is available.

Limitations of Nanny

Nanny is a pretty good software and probably the only Parental control system for Linux I know. But it connects the tasks with the respective applicaitons e.g. pidgin with chatting, thunderbird with emails and browser with web surfing. This seems logical but now a days each of these activities are possible on the browser. You can’t expect a 10-12 year old kid to use a mail client . There are tons of social networking sites out there that can keep him “busy”. Although my point seems a little vague here because you can manage and control websites the user can access using Nanny’s web content filtering system.

Another thing I noticed was the applists mentioned in /etc/nanny/applists. It is probably the list of applicaitons supported by Nanny. As of now, or as mentioned in my list, it supports only 3 browsers epiphany, firefox and konqueror. Since, browsing is the most important thing to be censored and monitored here, Nanny should add support for more browsers.


Posted by – May 18, 2010

Refers to:

Calling Qt Functions From Unix Signal Handlers

Posted by – May 18, 2010

Home · All Classes · All Functions · Overviews

Calling Qt Functions From Unix Signal Handlers

Refers to:
You can’t call Qt functions from Unix signal handlers. The standard POSIX rule applies: You can only call async-signal-safe functions from signal handlers. See Signal Actions for the complete list of functions you can call from Unix signal handlers.

But don’t despair, there is a way to use Unix signal handlers with Qt. The strategy is to have your Unix signal handler do something that will eventually cause a Qt signal to be emitted, and then you simply return from your Unix signal handler. Back in your Qt program, that Qt signal gets emitted and then received by your Qt slot function, where you can safely do whatever Qt stuff you weren’t allowed to do in the Unix signal handler.

One simple way to make this happen is to declare a socket pair in your class for each Unix signal you want to handle. The socket pairs are declared as static data members. You also create a QSocketNotifier to monitor the read end of each socket pair, declare your Unix signal handlers to be static class methods, and declare a slot function corresponding to each of your Unix signal handlers. In this example, we intend to handle both the SIGHUP and SIGTERM signals. Note: You should read the socketpair(2) and the sigaction(2) man pages before plowing through the following code snippets.

class MyDaemon : public QObject

MyDaemon(QObject *parent = 0, const char *name = 0);

// Unix signal handlers.
static void hupSignalHandler(int unused);
static void termSignalHandler(int unused);

public slots:
// Qt signal handlers.
void handleSigHup();
void handleSigTerm();

static int sighupFd[2];
static int sigtermFd[2];

QSocketNotifier *snHup;
QSocketNotifier *snTerm;

In the MyDaemon constructor, use the socketpair(2) function to initialize each file descriptor pair, and then create the QSocketNotifier to monitor the read end of each pair. The activated() signal of each QSocketNotifier is connected to the appropriate slot function, which effectively converts the Unix signal to the QSocketNotifier::activated() signal.

MyDaemon::MyDaemon(QObject *parent, const char *name)
: QObject(parent,name)
if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sighupFd))
qFatal("Couldn’t create HUP socketpair");

if (::socketpair(AF_UNIX, SOCK_STREAM, 0, sigtermFd))
qFatal("Couldn’t create TERM socketpair");
snHup = new QSocketNotifier(sighupFd[1], QSocketNotifier::Read, this);
connect(snHup, SIGNAL(activated(int)), this, SLOT(handleSigHup()));
snTerm = new QSocketNotifier(sigtermFd[1], QSocketNotifier::Read, this);
connect(snTerm, SIGNAL(activated(int)), this, SLOT(handleSigTerm()));


Somewhere else in your startup code, you install your Unix signal handlers with sigaction(2)

static int setup_unix_signal_handlers()
struct sigaction hup, term;

hup.sa_handler = MyDaemon::hupSignalHandler;
hup.sa_flags = 0;
hup.sa_flags |= SA_RESTART;

if (sigaction(SIGHUP, &hup, 0) > 0)
return 1;

term.sa_handler = MyDaemon::termSignalHandler;
term.sa_flags |= SA_RESTART;

if (sigaction(SIGTERM, &term, 0) > 0)
return 2;

return 0;

In your Unix signal handlers, you write a byte to the write end of a socket pair and return. This will cause the corresponding QSocketNotifier to emit its activated() signal, which will in turn cause the appropriate Qt slot function to run.

void MyDaemon::hupSignalHandler(int)
char a = 1;
::write(sighupFd[0], &a, sizeof(a));

void MyDaemon::termSignalHandler(int)
char a = 1;
::write(sigtermFd[0], &a, sizeof(a));

In the slot functions connected to the QSocketNotifier::activated() signals, you read the byte. Now you are safely back in Qt with your signal, and you can do all the Qt stuff you weren’tr allowed to do in the Unix signal handler.

void MyDaemon::handleSigTerm()
char tmp;
::read(sigtermFd[1], &tmp, sizeof(tmp));

// do Qt stuff


void MyDaemon::handleSigHup()
char tmp;
::read(sighupFd[1], &tmp, sizeof(tmp));

// do Qt stuff


Diagram Editor

Posted by – May 13, 2010

Ubuntu Diagram Editor:

Refers to:

Diagram Software for the rest of us!

With Gliffy online diagram software, you can easily create professional-quality flowcharts, diagrams, floor plans, technical drawings, and more.

Our online diagram editor makes it easier than ever to create great looking drawings.

1). Can edit diagram files suffixs with .dia
2). Can export dia file as a png file
3). Can draw UML diagram.

To install:
sudo apt-get install dia

Video for Linux Two API Specification

Posted by – May 12, 2010

Refers to:

V4L2 API Specification (Revision 0.24)

V4L2 Mini-FAQ

Q: That’s the V4L2 spec, what about V4L?
A: /usr/src/linux/Documentation/video4linux/API.html

Q: Are there any examples?
A: Yes, in the spec. Also a complete video capture example, source is capture.c.

Q: I have more questions.
A: Try the V4L Wiki or the Video4Linux mailing list.

IBM Mainframe

Posted by – May 6, 2010

Refers to: