Wednesday, January 12, 2011

How I got my webcam working in linux

1. Ran lsusb to get the vendor id and product id of the webcam plugged to the USB port. In the results found the line which corresponded to the webcam.
Bus 003 Device 004: ID 093a:2468 Pixart Imaging, Inc. SoC PC-Camera
Noted the vendor id and product id. In the above line, 093a is the vendor id and 2468 is the product id.

2. Now went to the website http://mxhaard.free.fr/spca5xx.html and found the driver corresponding to the vendor id and product id.
In my case it was spca5xx

3. Running sudo aptitude search spca threw up gspca-modules-2.6.26-2-686 which appeared appropriate.
I then installed it. sudo aptitude install gspca-modules-2.6.26-2-686

4. Ran sudo modprobe gspca to load the driver.

5. Checked if the webcam was working using cheese.

Friday, January 7, 2011

Starting conky on shell startup

All my attempts to start conky automatically on Linux startup have been unsuccessful. Now I have given up on that and am using a few lines of shell script to start conky on starting up the shell. As the first thing I do after starting up linux is to start the gnome-terminal, I have added a few lines to .bashrc to check if conky is running and if not to start it. I will have to do with this until a better solution can be found.



conky_ps=`ps -e | grep conky`
if [ "$conky_ps" = '' ]; then
conky -d
sleep 1
clear
fi

Wednesday, December 29, 2010

Download BBC programmes using get_iplayer

You can use get_iplayer to record BBC programmes available at the site bbc.co.uk/iplayer.

You can download get_iplayer from the below two sites
http://linuxcentre.net/getiplayer
http://www.infradead.org/get_iplayer/html/get_iplayer.html

You can search for bbc programmes at http://www.bbc.co.uk/programmes.

If the url of the programme you wish to record is for example www.bbc.co.uk/iplayer/episode/b00x44f3/Material_World_06_01_2011/ then its pid is b00x44f3 and you can record the programme using the command.
get_iplayer --type=radio --pid=b00x44f3

This will save the streamed data to the file Material_World_-_06_01_2011_b00x44f3_default_part01.wma

Thursday, December 16, 2010

Adding new fonts in linux

To install new fonts in linux(Debian),
1. Copy the fonts to the directory /usr/share/fonts/
2. Reload the fonts cache by issuing the command
fc-cache -vf

3. If the font server is running, make it reread the font databases in the current font path.
xset fp rehash

4. Restart the broswer
This should make the fonts available.


To confirm that the font, for example, 'meera' is available you can use the command
fc-list | grep -i meera


Links to malayalam fonts of some news websites are given below

1. Kerala Kaumudi - Thoolika
2. Malayala Manorama - Manorama
3. Mathrubhumi - Meera
4. Managalam - Meera
5. Metro Vaartha - VaarthaUni

Sunday, December 5, 2010

Running a command on multiple items in a directory with a long path

To run a command on more than one file or directory in a directory with a long path, curly braces can be used to group the files and directories together.

touch /a/really/long/path/id_{1,2,3,6}.txt
#creates 4 files named id_1.txt, id_2.txt, id_3.txt and id_6.txt in the directory /a/really/long/path/


mkdir /a/really/long/path/id_{1,2,3,6}
#makes 4 directories named id_1, id_2, id_3 and id_6 in the directory /a/really/long/path/


cat /a/really/long/path/id_{1,2,3,6}.txt
#echoes the contents of 4 files named id_1.txt, id_2.txt, id_3.txt and id_6.txt in the directory /a/really/long/path/


cp /a/really/long/path/id_{1,2,3,6}.txt .
#copies 4 files named id_1.txt, id_2.txt, id_3.txt and id_6.txt from the directory /a/really/long/path/ to the current directory


rm /a/really/long/path/id_{1,2,3,6}.txt
#removes 4 files named id_1.txt, id_2.txt, id_3.txt and id_6.txt from the directory /a/really/long/path/


rm -Rf /a/really/long/path/id_{1,2,3,6,{1,2,3,6}.txt}
#removes 4 directories named id_1, id_2, id_3 & id_6 and 4 files named id_1.txt, id_2.txt, id_3.txt & id_6.txt from the directory /a/really/long/path/

Thursday, December 2, 2010

Setting cron to email MySQL database backups using mutt

mysqldump --skip-lock-tables --host localhost -u Database_username -pDatabase_password Database_name | gzip > /home/user/etc/backup/`date +\%A`.sql.gz && mutt -s "`date +\%d_\%B_\%Y`'s backup" -a /home/user/etc/backup/`date +\%A`.sql.gz user@mail.com < /dev/null


The above command will dump the database to the server directory /home/user/etc/backup/ after compressing it. The name of the backup file will be the day of the week. eg: Sunday.sql.gz, Monday.sql.gz, ..., Saturday.sql.gz. This backup file will be emailed to user@mail.com as an attachment with a subject line, for example like 11_November_2010's backup.

This command should be set in cron to run once every day. Using the week day for naming the backup file ensures that only the latest 7 backup files will be present in the backup folder on server. Sending the backups to a gmail address will place them in the spam folder. Since each email in the spam folder is deleted after 30 days, any backup older than 30 days will be automatically removed.

So at any time, we will have the latest 7 days backup on the server and the latest 30 days backup in the email.

--all-databases can be used in place of Database_name to dump all the databases.

Specifying table(s) after Database_name will dump only the specified table(s), instead of the whole database.

Wednesday, December 1, 2010

List only directories using ls command

 ls -d */

Will list all directories in the current directory.

For example, ls -d /mnt/*/ will list the path of all the directories in /mnt/.

ls -d1 */ will list all directories in the current directory one per line.