Absolutely Tech

[SOLVED] Error “undefined reference to `libiconv_open’” while compiling

I was trying to compile sphinx server from source but I go the following errors on executing make

undefined reference to `libiconv_open’
undefined reference to `libiconv’
undefined reference to `libiconv_close’

To fix the error, you can compile without iconv (multiple encoding support) support. Use the following commands to compile. You can add more parameters as per your requirements.

./configure --without-iconv
make CFLAGS=-liconv
make install

I hope that helps

[HowTo] Use locate command and updatedb to search all partitions

Updatedb command by default does not include /media path for updating its database. You can change the settings in /etc/updatedb.conf so that it starts indexing other partitions too.

sudo gedit /etc/updatedb.conf

In the PRUNEPATHS setting, remove /media. Save the file and run

sudo updatedb

This will index all your files from /media folder. Make sure the partitions are mounted.

Cheers!

[HowTo] Suspend Ubuntu from terminal or keyboard shortcuts

When learning to make bash scripts, at one point or other you’d like to know how to suspend your computer from terminal. Well, there are quite some methods available for Ubuntu. You can choose whatever suits your needs. I prefer method 3 (look below).

Method 1:

sudo sh /etc/acpi/sleep.sh force

Method 2:

sudo pm-suspend

This command might not be available in older versions of Ubuntu. It works perfectly fine on Lucid and Maverick.

Method 3:

This command does not require sudo so it might come in handy. For example, you can map it to a keyboard shortcut for easy access.

dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

One thing to notice here is none of the commands I mentioned here will ask your password on resuming. For that you’ll have to lock your computer before suspending. You’ll have to use gnome-screensaver-command --lock before suspending to lock the computer

Create a suspend script:

Open a new file in gedit:

sudo gedit /usr/bin/suspend-comp

Copy and paste the following code and save it:

#!/bin/sh 
sleep $1;
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

If you want the script to ask for a password on resuming, copy-paste this code instead:

#!/bin/sh 
sleep $1;
gnome-screensaver-command --lock
dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend

Add the executable bit:

sudo chmod +x /usr/bin/suspend-comp

Now suspend-comp time-in-seconds can be used in terminal. For example, if I want to have my computer suspended after 20 seconds I can simply type:

suspend-comp 20

Mapping it to keyboard shortcut for easy access:

Go to System->Preferences->Keyboard Shortcuts. Click Add. Type Suspend for Name and suspend-comp 0 in Command field. Click Apply.

Now scroll to the bottom of the list to find Suspend. Click on ‘Disabled’ on the right to ‘Suspend’. Now press any key combination to map the command to it. I used Ctrl+Alt+Shift+s.

Now simply pressing Ctrl+Alt+Shift+s will suspend your computer.

Cheers!

[HowTo] Find number of files inside a folder in Linux

I wanted to find out the number of files inside a folder. I didn’t want the folders to be included in the result.
A blog post on zimbio.com shows us how to do it with ls command which is not only downright inaccurate, it is also slower than what I am going to show you.
I am going to show you how to do it using find command which is extremely powerful once you know how to use it.
Executing the command below will print the number of files (excluding folders) in current directory (including all subdirectories):

find ./ -type f | wc -l

This can be used to find number of directories too:

find ./ -type d | wc -l

You can do more complex counting for example finding out the number of files which are of filesize 1Mb and more.

find ./ -type f -size +1M | wc -l

Finding number of symlinks:

find ./ -type l | wc -l

You can also see number of files accessed within last 1 hour from current directory:

find ./ -type f -amin -60 | wc -l

Here -60 means less than 60 minutes ago.

Only imagination is the limit with what you can achieve using find command.

[HowTo] Enable or disable modules in Apache

You can enable or disable any apache module using a2enmod and a2dismod. You don’t need to edit the conf file for that unless you are having some problem with this method. The syntax of these commands is really simple:
To enable a module:

sudo a2enmod module_name

To disable a module:

sudo a2dismod module_name

Read the rest of this entry »

[HowTo] Use mutt with msmtp

Mutt is a small but very powerful text-based mail client for Unix operating systems. Msmtp is a smtp client which is available for Linux as well as windows.
Configuring mutt to work with msmtp is fortunately quite easy. Here’s a tutorial teaching the same.
Step 1:
Find the executable path of msmtp:

which msmtp

Step 2:
Just open ~/.muttrc using a text editor and add the following code to it:

send2-hook '~f fromaddress@example.com' 'set sendmail="PATH"'

Replace PATH with the executable path of msmtp and replace fromaddress@example.com to the FROM address you want in your email address to appear. For me the code looks like the following (on Ubuntu 10.10):

send2-hook '~f dpac.mittal2@gmail.cm' 'set sendmail="/usr/bin/msmtp"'

Try sending a mail with mutt and it should succeed.

Cheers!

[HOWTO] Send emails(using mail function) from localhost in PHP through msmtp (using gmail account) on Linux

There’ve been lots of times when I wanted to use the mail() function on my local server. I am sure lots of you would’ve been wanting it too but most of you would’ve settled for PHPMailer or just used a web host to test the code instead. I myself had been doing the same until recently when I finally decided to do some research and get it to work.

Here are the steps in short for the geeks who like to do things on their own:
All I did was used smtp client called msmtp, configured it to work with my gmail account and configured PHP to use msmtp to send emails.

This tutorial is only applicable for linux users. I’ll write another article for windows users soon when I get my hands on a windows box.
All the commands used in the instructions are for Ubuntu, however you may use corresponding commands for your distro (for eg; you can use yum install instead of apt-get install on fedora, redhat, centos.

Step by step instructions:

Read the rest of this entry »

[HowTo] Configure msmtp to work with gmail on linux

Msmtp is a small but powerful and highly customizable smtp client. You can access gmail smtp using msmtp, which is exactly what I’ll teach in this tutorial.

Step by step instructions:

  1. Install msmtp and ca-certificates for use with SSL:
    sudo apt-get install msmtp ca-certificates
  2. Read the rest of this entry »

[SOLVED] No module named gtkhtml2

I came across this error while trying to run BloGTK.

I tried installing it from repositories but it failed:

sudo apt-get install python-gtkhtml2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python-gtkhtml2 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package python-gtkhtml2 has no installation candidate

There’s a bug filed for this.

To solve the error, I downloaded the appropriate .deb package from here and installed it:
http://packages.ubuntu.com/karmic-updates/python-gtkhtml2

For maverick users, you’ll have to download and install libgtkhtml2-0 package from the following site to solve dependency issue of python-gtkhtml2 :
http://packages.ubuntu.com/lucid/libgtkhtml2-0

Cheers!

[HOWTO] 5 methods to find out your linux distribution name and version through command line

There are lots of commands to find out your ditribution name and distribution version. Some work on some distros, some work on others. Here are some of the methods:

  • lsb_release -a

  • cat /etc/*release

  • cat /etc/issue

  • cat /proc/version

  • uname -a

One of these methods will surely tell you your linux distribution name and current version.

Cheers!