Category: Blog

Take Screenshots in Xfce

ImageMagick must be installed for this to work.

Create a file named screenshot, and paste this into it.

xwd -root | convert xwd:- ~/Desktop/screenshot.png

Run this command to make the file executable.

$ chmod +x screenshot

Run this command to move the file to /usr/bin.

# mv screenshot /usr/bin/screenshot

Open the Xfce menu -> Settings -> Keyboard Settings. Go to the Shortcuts tab, and add a new theme. Now add a shortcut; type screenshot for the command, and press the Print Screen key when it tells you to set the shortcut.

Now when someone posts yet another “show your desktop” thread, you won’t have to feel left out!

Organizing Files by File Type


Run this, replacing /current/folder/ with the folder the files are in, .filetype with the file type, and /new/folder with the folder you are moving the files to.

$ mv /current/folder/*.filetype /new/folder

Tip: Don’t reinvent the wheel.


I have a lot of images, and I wanted to separate all of my .gif’s from the main folder, so this is what I did.

Create a file named organize_files, and paste this into it.

cd $2
for i in *$1; do mv `basename $i $1`$1 $3; done

Make it executable.

$ chmod +x organize_files

Move it to /usr/bin.

# mv organize_files /usr/bin/organize_files

Now, to move your files, make the directory you want to move them to, and run this.



My pictures are in /home/kevin/pictures and I want my .gif’s in /home/kevin/gifs

$ organize_files .gif /home/kevin/pictures /home/kevin/gifs

Install Twiki on Ubuntu

This is a short guide on how to install Twiki 6.0.0 on Ubuntu 14.04.

Install all of the relevant dependencies.

sudo apt-get installapache2 libgdal-perl libcgi-session-perl 
libhtml-tree-perl liberror-perl libfreezethaw-perl libjpeg62 
rcs libapache2-mod-perl2-doc libapache2-mod-perl2 
libapache2- mod-php5 latex2html

Download Twiki

If installing in the default directory for Apache (/var/www/html) place the downloaded zip/tar.gz

file in

/var/www/html (

Install Twiki

cp /var/www/html/twiki/bin/LocalLib.cfg.txt  /srv/www/html/localhost
chown -R www-data:www-data /var/www/html/twiki

Configure Twiki
Go to this link and have the page generate the configuration needed for your apache and perl


Save the generated configuration to /etc/apache2/conf.d/twiki.conf

Restart Apache2

sudo /etc/init.d/apache2 reload

Allow configuration file to know where the path to the configuration should be put.

Edit /var/www/html/twiki/bin/LocalLib.cfg:

     $twikiLibPath = "/var/www/html/twiki/lib";

Run Twiki config.
Configure your twiki: go to http://localhost/twiki/bin/configure, setup admin password

and paths.

Edit /var/www/html/twiki/bin/LocalLib.cfg:

     $twikiLibPath = "/var/www/html/twiki/lib";

Note : Do not forget to enable cgi.load by

sudo a2enmod cgi
sudo service apache2 restart

Enable the conf.d directory created by you for twiki.conf file in apache2.conf file.

Stop CPU beep in Ubuntu/Debian

The CPU beep is a really irritating thing in Linux distros and sometimes the graphical sound manager does not work when shutting it up.

Fortunately there is a simple way to do it in terminal. In Ubuntu (and distros based upon it) type:

gksudo gedit /etc/modprobe.d/blacklist

In Debian type:

gedit /etc/modprobe.d/blacklist

And add the following line to the file:
blacklist pcspkr

Save it and reboot. Now the CPU beep should be disabled!

Webalizer across multiple vhosts

Was looking for a way to get webalizer to include stats for all the vhosts on my server and cobbled together this script to run in cron…

cd $logloc
ls | egrep -v 'error|gz|sh|webalizer' | xargs cat > $file
ls | grep gz | egrep -v 'error|sh|webalizer' | xargs gunzip -c >> $file
echo "Sorting $fname"
sort -t ' ' -k 4.9,4.12n -k 4.5,4.7M -k 4.2,4.3n -k 4.14,4.15n -k 4.17,4.18n -k 4.20,4.21n $file > $file.sorted
echo "Runnig Webalizer"
webalizer 2> /dev/null
rm $file
rm $file.sorted
echo "Complete"
exit 0

This grabs data from all my vhost’s access.log files in my apache2 directory, concatenates them into one file, sorts it into date order, and then runs all of it through webalizer. It’s handy to see just how much punishment the web server is putting up with, and what is being accessed the most.

Oh, for this to work you have to setup webalizer with the following line of config config:

LogFile /var/log/apache2/webalizer.sorted

Obtaining network interface information with dladm

Remember the good old days when you had to use ndd to know whether network interfaces on your machine negotiated the bandwidth and duplex settings correctly? And to make matters worse some interfaces would have slightly different ndd getters to obtain that information, which was fairly frustrating sometimes. Well, it’s been a long time coming, but with Solaris 10 you don’t have to that any more. A new fangled dladm utility takes care of abstracting the details of underlying network interface driver and can obtain the details of available network interfaces in a rather simple but quite useful format, all you have to do is invoke dladm with “show-dev” parameter (as on one of my systems):

# dladm show-dev
bge0 link: up speed: 100 Mbps duplex: full
bge1 link: up speed: 1000 Mbps duplex: full
bge2 link: up speed: 1000 Mbps duplex: full
bge3 link: unknown speed: 0 Mbps duplex: unknown

Finding Files with Spaces in Filenames

I guess I’m too old school, I still don’t like using a blank space as a separator between words in a file name — with every opportunity I replace the blank spaces with underscores because white spaces always trigger bugs in many file handling scripts. Unless every command in the script that works with file name can account properly for blank spaces in the file name, you’re risking some funny behavior produced by your otherwise “working-fine” script. One frequent annoyance is when you’re running find on a directory full of files with names containing spaces and trying pipe the output to xargs for further processing. Assuming I’m trying to search for files containing either “foo” or “bar” strings in their contents in the directory containing the following file names:

# ls -1
My Expenses
My Trip
Things To Do

Well, running find is not looking so good with the regular arguments:

# find . -type f -print | xargs egrep "(foo|bar)"
egrep: can't open ./My
egrep: can't open Expenses
egrep: can't open ./My
egrep: can't open Trip
egrep: can't open ./Things
egrep: can't open To
egrep: can't open Do

Not very useful, since find pipes its results as a single string and xargs just breaks it into separate arguments using spaces. The way to make this work is to force the find command to delimit each of the filenames with null character and make xargs to honor these delimiters, so it becomes very simple:

# find . -type f -print0 | xargs -0 egrep "(foo|bar)"
My Expenses:foo
My Trip:bar

One big drawback for this technique is that it is not universal, if you don’t have the GNU version of find and xargs, well, you’re pretty much out of luck. Which would apply to most of us running “classic” Unix systems. The other technique is slightly more subtle using the -exec switch in find, but of course you loose some of the niceties associated with xargs:

# find . -type f -exec egrep -l "(foo|bar)" "{}" \;
./My Expenses
./My Trip

It’s Official – Linux is better than Windows

Yep, you read this right. I’m officially declaring Linux to be more usable than Windows (provided of course that there is parity in available application software). The reason I’m saying this is Linux and Ubuntu in particular has passed the litmus test of usability in my book – my wife has declared Ubuntu Linux to be more pleasurable for use than Windows XP. I can’t say that my wife is passionate about computers, she is a journalist and sees computers and by extension operating systems as just another tool that gets her job done. So there are no emotional ties to any vendor or particular implementation on her part, her approach to computers is purely utilitarian and whatever OS gives her the least amount of anguish wins at the end of the day.

My has been a long time user of Windows and believe it or not it took a little bit of convincing to move her to a Mac, which she now absolutely loves. So she’s Mac OS X on her desktop, but the laptop she’s been lugging around has been running Windows XP up until now. And like with any Windows installation that just somehow mysteriously disintegrates over time (slow boot times, annoyingly slow wake-ups from hibernation, growing suspicions that the laptop in infected with a virus, etc.) , my wife started dreading using her laptop and would simply postpone her work till she gets to the desktop just to avoid the pain and anguish of using it. I can’t blame her, I would have done the same thing. So I decided to shrink the Windows partition and make the laptop dual bootable with Ubuntu Linux.

Installation went without a single hitch and choice of software satisfied all of my wife needs for her professional work – Firefox for web browing, Thunderbird for email and calendar, OpenOffice for office application, vpnc to vpn into a Cisco based VPN network. What do you know, my wife started using the laptop again and she loves it! Using the laptop feels a fair bit more snappier than with Windows XP, there is stronger feeling of security with Linux, and sharing files between the laptop and other computers is actually easier. I don’t think my wife will want to go back to Windows any more.

So there you have it, if a fairly non-technical computer user who is purely utilitarian in its approach to operating systems finds Linux more usable that Windows, well, it is a clear win for Linux and Ubuntu in particular in my book. Very well done for the Ubuntu folks! I really hope the goodness of Linux keeps on catching on among non-techies.

How to Gain Root Access in Ubuntu

In Ubuntu you are restricted to using a normal user. You must type sudo before any useful command to get it to work. When you are ready to move up to root status on your machine, here is how you can do so.

username@my-machine~# sudo su -
Enter password: (put in your password)

You can also set root’s password by doing this as a normal user:

username@my-machine~# sudo passwd root
New UNIX password:
Retype new UNIX password:

After doing that you may now change to root by doing just:

username@my-machine~# su -