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):
This can be used to find number of directories too:
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:
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.
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.
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.
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
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.
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.
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.
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:
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.
Find the executable path of msmtp:
Just open ~/.muttrc using a text editor and add the following code to it:
Replace PATH with the executable path of msmtp and replace [email protected] to the FROM address you want in your email address to appear. For me the code looks like the following (on Ubuntu 10.10):
Try sending a mail with mutt and it should succeed.
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:
- First of all, follow this tutorial:
Install msmtp on your linux box and configure it to work with Gmail.Msmtp is highly configurable and you can easily configure it to work with any smtp server. If you wish to use any other service with msmtp, you may read its manual and configure it.
Proceed to next step only if you have successfully configured and are able to send a test message.
- Open php.ini in your text editor.
sudo gedit /etc/php5/apache2/php.ini
Search for ‘sendmail_path’ and change it to look like
sendmail_path = '/usr/bin/msmtp -t'
Save the file and exit the text editor.
Please note that your msmtp path may vary if you are not using Ubuntu. You may find the path to executable by:
- Restart apache:
sudo /etc/init.d/apache2 restart
sudo /opt/lampp/lampp restart
- Everything’s done. Lets test if the mail() function is working now:
if ( mail ( '[email protected]', 'Test mail from localhost', 'Working Fine.' ) );
echo 'Mail sent';
echo 'Error. Please check error log.';
Replace the [email protected] with your own username, save it into a php file along with php delimeters in your virtual host root folder and execute it through the browser. You should receive a mail.
Give yourself a pat on the back.
Some points to note:
- If you weren’t able to send yourself a test mail in Step 1 ie. setting up msmtp, you should look at the debug information and search for solutions accordingly on the internet. Here’s the manpage of msmtp to help you with configuration
- If you didn’t receive a mail in your inbox on the last step, check in your Spam folder. If its not there your should check the php error log for hint about what went wrong and act accordingly.
- For any other questions, suggestions or appreciation feel free to use the comment box.
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:
- Install msmtp and ca-certificates for use with SSL:
sudo apt-get install msmtp ca-certificates
- We’ll create and edit the configuration file using Gedit:
Now copy and paste the following code in the text editor:
user [email protected]
from [email protected]
Needless to say, you have to replace [email protected] with your email and mypass with your password
- It should be readable by anyone. However, we’ll still execute the following command to be sure.
sudo chmod 0644 /etc/msmtprc
- Your msmtp configuration is ready. Lets send a test email to yourself to see if everything’s working properly:
echo -e "Subject: Test Mail\r\n\r\nThis is a test mail" |msmtp --debug --from=default -t [email protected]
Again replace [email protected] with your own email address and execute it. You should receive an email.
These are the exact commands to be used with Ubuntu.
You can replicate the steps for another distibution by using equivalent commands (For eg; yum install in place of apt-get install for centos, redhat, fedora.)