Absolutely Tech

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

[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] ‘Unknown’ filesystem in gparted

I had a primary NTFS partition with windows 7 installed on it. Somehow, its bootloader went corrupt so I used install-mbr in ubuntu to fix that but it only made the problem worse. Now my system didn’t recognise the partition as NTFS partition and I couldn’t access the partition.

I modified the partition ID using fdisk but that didn’t work. Fdisk recognised it as NTFS but gparted didn’t, nor did Ubuntu. To fix it, I followed the following steps:

    • Download testdisk and extract the files to a folder. The files are compiled executable files so there is no need for any installation. I extracted it in a folder named testdisk on my home directory. Ubuntu users can install it using sudo apt-get install testdisk
      cd ~/testdisk/linux
      Execute the testdisk:

      sudo ./testdisk_static
      Select [Create] and press enter. On the resulting screen, select your harddrive using cursor keys and press enter. On the next screen select the partition table type. It’d generally be Intel if you are using a PC and Mac if you are on Mac. Select the correct one and press enter.
      Now you’ll be presented with lots of options. Use cursor keys to select Advanced and press enter. Select the partition which shows unknown type. Use left and right arrow keys to select [Type] and press enter. You’ll see the list of partition types. In the list the HPFS/NTFS has partition id 07. Press enter, type 7 for NTFS or another partition ID corresponding to your partition type. Press enter.
      Now use the right arrow key to select the [Boot] and press enter. Use right arrow key to select [Rebuild BS] and press enter. Select [Write] and press enter. Now type y. The partition should be fixed by now. You can now quit the testdisk
      Refresh partition list

      sudo partprobe
  • The disk should be accessible again now

    Cheers!

    [Solved] Subtitles not being displayed in VLC in Ubuntu

    I had this problem where subtitles were not being shown in VLC. No matter what I did, it just wouldn’t display. I reinstalled VLC but still it had problems. So I removed all the vlc config files to reset the settings and fix the problem.

    rm -rf ~/.config/vlc
    

    That fixed it.

    Cheers!

    [SOLVED] No sound in tuxguitar

    Tuxguitar stopped working after upgrading to Ubuntu 10.10 Alpha. Many people seem to be having this problem after a distribution upgrade.

    The fix is simple. Install timidity and tuxguitar-jsa package.

    sudo apt-get install timidity tuxguitar-jsa

    After the install, run tuxguitar and play a file. You should hear the sound. If you still cannot hear it play, goto Tools->Settings->Sound
    In the MIDI Sequencer drop down list, select ‘Real Time Sequencer’. In the MIDI Port field, select ‘Gervill’ and click on Ok. Click on Yes when it asks for confirmation.

    Try and play sound again, and you should here it this time.

    Ubuntu 11.04 named ‘Natty Narwhal’

    Ubuntu 11.04, which is to be released in April 2011, has been named Natty Narwhal as mentioned on Mark Shuttleworth’s blog.
    Check out the entire blog post here.

    Seems reasonable, as weird sounding as all previous names. Ubuntu, you never disappoint me!

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

    [Solved] vlc: missing mandatory argument `–user-agent=”VLC media player”‘

    Yesterday after upgrading the packages VLC refused to start giving out following error message:

    VLC media player 1.1.1 The Luggage (revision exported)
    vlc: unknown option or missing mandatory argument `--user-agent="VLC media player"'
    Try `vlc --help' for more information.

    To solve the error, just reinstall vlc:

    sudo apt-get install vlc

    Cheers!

    Ubuntu 11.04

    The next version of Ubuntu is coming soon

    Follow me

    Sponsors