...making Linux just a little more fun!

2-Cent Tips

2-cent tip - KDE 4.1 on 10 year old PC

oscar laycock [oscar.laycock08 at googlemail.com]

Mon, 17 Nov 2008 14:53:22 +0000

I thought you might be interested to know that the latest KDE 4.1 runs surprisingly well on my 10 year old PC. It is only a 350mhz Pentium 2 with 128mb of swap. I built KDE myself - you just run "cmake" instead of configure. I have also done some Qt programming, though sometime I have to increase the swap by 200 or 300 meg.

I simplified Linux from Scratch (LFS). I run a 1998 version of Red Hat Linux(!) alongside my new stuff in /usr/local. I hardcode in a rpath to the new libraries when compiling new programs.

I would encourage everyone to try LFS (www.linuxfromscratch.org). I only knew a little Unix and some C when I started. It is fun, you learn a lot, and get a great sense of achievement.

2-Cent Tip: LG search plugin

Ben Okopnik [ben at linuxgazette.net]

Wed, 19 Nov 2008 20:22:34 -0500

If you use Firefox, you're probably addicted to its oh-so-nifty little search bar (how did we ever live without those?) What you may not know, though, is that you can add your own entries to that pull-down list - all you need is a properly-formatted search URL, a bit of XML and maybe a Base64-encoded icon. So, for those of you who want to search LG in the easiest way possible, here it is; save it as '~/.mozilla/firefox/<profile>/searchplugins/lg.xml', restart Firefox, and enjoy!

[ ... ]

[ Thread continues here (1 message/3.60kB) ]

2-cent Tip: command line calendar with cal

Mulyadi Santosa [mulyadi.santosa at gmail.com]

Tue, 11 Nov 2008 00:51:50 +0700

A quick way to show current month's calendar is by executing "cal" command. By default, it will show current month calendar.

Should you need to show calendar of certain month and year, simply type it as parameter. For example:

$ cal 1 1979
will show you calendar of January 1979



[ Thread continues here (9 messages/9.48kB) ]

2-cent Tip: To solve memory allocation problem in Cacti

Mulyadi Santosa [mulyadi.santosa at gmail.com]

Sun, 23 Nov 2008 10:20:48 +0700

This kind of problem doesn't manifest in explicit message. What you see is just graphs that disappear. But it will become clear when you run the poller directly like this:

$ sudo -u cacti /usr/bin/php /var/www/cacti/poller.php
Allowed memory size of 8388608 bytes exhausted (tried to allocate 12 bytes)

At first, one might think it's something related to ulimit and rush to change stack size limit for example. But that's not the problem. The problem lies in php CLI (Command Line Interface) which tries to allocate memory in stack in order to prepare data to be shown in graph tree and so on.

In Ubuntu, try to edit this line in /etc/php5/cli/php.ini:

memory_limit = 8M

8 Megabyte might be too low especially you poll hundreds of devices, so try to rise the number. From some reference, it is declared that 128 M is the maximum size of memory PHP CLI can allocate in stack.



2-cent Tip: File versioning/backup

Ben Okopnik [ben at linuxgazette.net]

Sat, 1 Nov 2008 23:32:43 -0400

[For some reason, I thought I'd submitted this ages ago; searching LG shows that I was apparently wrong.]

There are lots of times - e.g., when you're editing a critical file, or want to keep multiple versions of a script that you're developing - that you want to take a snapshot of your current directory, or at least of some of the files within it. I've been using the following script for the past several years, and it's proven to be flexible, powerful, and fully sufficient for the task.

Note that you can also define a ".backup" file within the directory (this should contain the names of the files to be backed up, one per line) so you can run "backup" without any arguments and still have it snapshoot the right files. Enjoy!

# Created by Ben Okopnik on Wed Jan 26 21:48:05 EST 2005
name="`/usr/bin/printf $0|/bin/sed 's|.*/||'`"
usage () {
cat <<!
	$name -h
	$name [-a] [file[s]]
	-h	Show this help
	-a	Back up all specified files unconditionally
	The list of files to be backed up can be defined either in a
	.backup file in the current directory, on the command line, or as a
	combination of the two. The files will be saved in a "backup"
	subdirectory, with a timestamp extension appended to their
	If the latest archived copy of a specified file does not differ
	from the current version, the file will not be backed up unless the
	"-a" option is used.
case "$1" in
	-h) usage; exit ;;
	-a) do_all=1; shift ;;
	-n) no_file=1; shift ;;
backup () {
	# Create a backup directory if necessary
	[ -d "backup" ] || {
		[ -e "backup" ] && { 
			echo "Error: $PWD contains a file called 'backup': can't create a 'backup' directory!"
		echo -n "Creating 'backup' directory... "
		mkdir backup
		[ "$?" -eq 0 ] && echo "Success!" || { echo "Failed - exiting."; exit; }
	for file in "$@"
		[ -f "$file" ] || { printf "$file not found!\n"; continue; }
		# Find the last backup for each file
		latest="`ls backup/$file.20[0-9]* 2>/dev/null|tail -1`"
		[ -z "$latest" ] && do_all=1
		if [ "$do_all" = "1" ] || [ -n "`diff -q $file $latest`" ]
			cp -i "$file" "backup/$file.`date +'%Y%m%d%H%M%S'`"
			saved="$saved $file"
			nodiff="$nodiff $file"
	[ -n "$saved" ] && echo "Backed up: $saved"
	[ -n "$nodiff" ] && echo "NOT backed up (identical files in archive): $nodiff"
[ "$no_file" = 1 ] || { [ -f ".backup" ] && set "$@ `cat .backup`"; }
if [ -n "`echo $*|grep '[^ ]'`" ]
	backup $@
	echo "No files specified and no ./.backup file found; exiting."
	exit 1
* Ben Okopnik * Editor-in-Chief, Linux Gazette * http://LinuxGazette.NET *

[ Thread continues here (5 messages/8.30kB) ]

Talkback: Discuss this article with The Answer Gang

Copyright © 2008, . Released under the Open Publication License unless otherwise noted in the body of the article. Linux Gazette is not produced, sponsored, or endorsed by its prior host, SSC, Inc.

Published in Issue 157 of Linux Gazette, December 2008