[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!

[Solved] apt-get “is to be installed” errors in Ubuntu

This class of error means the dependency is of different version than required. I tried to install deluge-console but it gave me the following error:

deluge-console : Depends: deluge-common (= 1.3.0-0ubuntu1) but 1.3.0-1~getdeb1 is to be installed

The error is not that self-explanatory. Here the deluge-common version required by deluge-console is 1.3.0-0 but 1.3.0-1 is installed. This means that I have newer version of a dependency required by the application I am trying to install.

Fortunately, you can force the version in apt-get:

sudo apt-get install deluge-common=1.3.0-0ubuntu1

I forced an older version, downgrading the package. This fixed the error for me and I could successfully install deluge-console after that.

This method can be applied to fix problems in other applications as well.

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] Open thumbs.db and extract thumbnails from it

Thumbs.db is a file used to store thumbnail data of a folder in Windows. It makes loading of thumbnails significantly faster, however it has some privacy issues. Like if you delete an image, its thumbnail might still be there in thumbs.db file which would allow you to view it.

There’s an open source python script called Vinetto available to extract all the thumbnails in open.db to a folder. It works on Linux, Windows and Mac OS. You can download the script from here.

On Ubuntu, you can use apt-get to install vinetto:

sudo apt-get install vinetto

To extract thumbnails:

vinetto -o ./thumbnails ./thumbs.db

This will extract all the thumbnails inside thumbs.db to thumbnails folder.

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.

[SOLVED] Unable to find the Jasper image conversion program in Kopete

Kopete supports yahoo webcam and it works seamlessly. Although it doesn’t work right away after installing kopete. If you try to access anyone’s webcam you’ll get the following error.

Unable to find the Jasper image conversion program.
Jasper is required to render Yahoo webcam images.
Please see http://wiki.kde.org/tiki-index.php?page=Kopete%20Webcam%20Support
for further information.

You can fix it simply by installing jasper packages available in Ubuntu repositories:

sudo apt-get install jasper libjasper-java libjasper-runtime libjasper-dev libjasper1

You can now send and receive anyone’s webcam.

Cheers!

[SOLVED] TERM environment variable not set in Guake

After upgrading to Maverick Meerkat yesterday, my Guake terminal started giving the following error on executing top:

TERM environment variable not set.

You can fix the error by doing exactly what error says – set the TERM variable. To do that execute the following in terminal:

echo -e "TERM=xterm\nexport TERM" >> ~/.bashrc

Kill the guake terminal

kill -9 $$

You don’t need to run guake again, just press your keyboard shortcut to bring back Guake and it will appear. Now you can execute commands as normal.

Cheers!

[SOLVED] UNMOUNTABLE_BOOT_VOLUME upon booting in Windows 7

I was fixing my friend’s computer hard drive whose partition structure had gone corrupt. I restored the partition structure using testdisk. However, on booting through this hard drive, BSOD appeared. It said UNMOUNTABLE_BOOT_VOLUME. The hard drive was perfectly healthy, so the error looked a bit out of place. I looked into google and found that most of the people who had this error had 2 SATA drives. My friend had 2 SATA drives too.

So, I switched the cables (connected HDD1 with HDD2’s cable and vice versa) and voila! It worked!

If that doesn’t work for you, you can remove the other drive completely and see if the problem is really with having 2 drives. You can also try replacing the cables with new one.

Cheers!