Locating files on linux using find

A very powerful tool on linux systems is the find command. It is used to locate file in the system across directories.


amit@texens:~$ find

It takes in the location to be searched, and the criteria. It can search using criteria such as file name, owner, group, file permission, last edit time etc. It is recursive in nature, that is it looks into the folders recursively.


amit@texens:~$ find . -name foobar

will list all the files with the name foobar.

See manpage for find for more information.

Note: grep is different from find in the way that grep looks for content inside the files wheras find locates files itself and not the content inside them.

Exclude svn files while copying in linux

SVN recursively populates .svn folders in all the children folders of a project under version control. There are a number of techniques to copy the parent folder without copying the .svn folders and files, but I find the following to be easiest and quickest.

amit@texens:~$ rsync -aC /path/to/srcdir/ /path/to/destdir

The trailing “/” on srcdir is to make sure that the contents of srcdir are copied to destdir. Without the trailing “/”, the destdir will contain the srcdir and everything will be one more level down.

One other option is to copy the directory without paying any heed to the .svn directories and then find and delete all the .svn folders using the following command.

amit@texens:~$ cp -r /path/to/srcdir/folder /path/to/destdir
amit@texens:~$ find /path/to/destdir -name '.svn' -exec rm -r {} \;

Bitwise 2010 Winners

Bitwise, the Annual Algorithm Intensive Online Coding Contest organised by the Department of Computer Science and Engineering, Indian Institute of Technology, Kharagpur was held on 14th February, 2010. It saw the largest participation, in the terms of both – the number of participants as well as the number of countries.

There were a total of 6000 participants forming 3151 teams from 65 countries. But the bulk of countries came from India, United States, Bangladesh, China and Russian Federation.

This year, Enigma was somewhat easier, at least the long list of winners says so. This puzzle game was inspired by the Enigma machine which was used by the Nazis to encrypt and decrypt messages during the second World War. It consists of images and a hint to crack it. It has 30 levels, and all those who are successful in cracking them all enter the Enigma hall of fame.

The main coding event started at 1200 Hrs (IST) and concluded at 2359 Hrs (IST). In an amazing change over the previous years, this time there wasn’t any single team that dominated the event throughout the competition. Teams climbed up and descended down throughout the 12 hour period.
The first team to crack any problem was urbo, from the University of Latvia. Setting a new record in the history of Bitwise, they cracked the problem in just within 30 minutes of being uploaded. This certainly has been the best time ever made.

urbo was soon followed by teams – Eryx (Warsaw University), Excalibur (TSinghua University), 2/3 ubc^ (University of British Columbia), and Two Headed Monkey (KTH – Royal Institute of Technology & New York University). The teams went up and down and the last two hours saw the team – ajaysomani from google, climb up to second spot.

The final Rankings are as follows:

  1. Eryx, Warsaw University, Poland
  2. ajaysomani, Google, India
  3. urbo, University of Latvia, Latvia
  4. rem and _pperm, Perm State University, Russian Federation
  5. Two-Headed Monkey, KTH – Royal Institute of Technology & New York University, Sweden
  6. NiN, NNSU, Russian Federation
  7. 2/3 ubc^, University of British Columbia, Canada
  8. aryans, IIIT, Hyderabad, India
  9. daemons, Jagiellonian University, Poland
  10. Deadly Coding Squad, ITESM CQ, Mexico

You can download the solutions to the Bitwise 2010 Problems here and enigma answers can be found here.

The Bitwise 2010 team at the Software Lab.

Bitwise 2010 team
Bitwise 2010 Team (Diptesh behind the cam)

Auto mount partition in ubuntu

I have a dual boot system consisting of 3 partitions – one for windows, one for ubuntu and a bulky MEDIA drive that I share with both of them as it contains all my media files like Music and Videos.

The easiest way to mount a partition automatically to a destination is by editing the fstab.

Open the terminal and determine the device to be mounted.
You need to be root in order to see the disk list

amit@texens:~$ sudo su
[sudo] password for amit:

Use fdisk -l to determine the disk

root@texens:/home/amit# fdisk -l

You’ll get something like this

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x54e308d9

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 102400 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sda2 13 6528 52326400 7 HPFS/NTFS
/dev/sda3 6529 33523 216837337+ 5 Extended
/dev/sda4 33524 38913 43295175 83 Linux
/dev/sda5 6529 33274 214837213+ 7 HPFS/NTFS
/dev/sda6 33275 33523 2000061 82 Linux swap / Solaris

Note, the line

/dev/sda5 6529 33274 214837213+ 7 HPFS/NTFS

/dev/sda5 is the partition that we want to mount. Make a note of it.

Now we’ll edit the fstab file located at /etc/fstab.
Again you need to be root in order to edit the fstab file.
Make sure you are the root and use an editor of your choice to edit the file. I’ll be using vi editor for the same.

root@texens:/home/amit# vi /etc/fstab

The fstab file looks something like this.

# /etc/fstab: static file system information.
# Use 'vol_id --uuid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
proc /proc proc defaults 0 0
# / was on /dev/sda4 during installation
UUID=1e6770f3-7cd7-4be9-b6f0-3c30f96f852f / ext3 relatime,errors=remount-ro 0 1
# swap was on /dev/sda6 during installation
UUID=232230d0-236c-4e62-9c05-99b61d48b23e none swap sw 0 0

Now, all we need to do is to add the
I want to mount the partition to the location /media/bulk
Create the folder /media/bulk

root@texens:/home/amit# mkdir /media/bulk

Now, add the following line to the end of the file.

/dev/sda5 /media/bulk ntfs-3g defaults,locale=en_US.utf8 0 0

And save this file.
Now, hit the mount command to mount it just this time.

root@texens:/home/amit# mount -a

Next time when you boot into your computer, it will be automatically mounted at its designated position.

Bitwise 2010 – promising to be bigger than ever..!

Its been just 7 days since the registrations for participation in Bitwise – An Annual Algorithm Intensive Online Programing Contest hosted by Department of Computer Science and Engineering, IIT Kharagpur started. And we have crossed the magic figure of 1000 already. Thanks to all the participants 🙂

What is more interesting is the statistics and the geographical distribution of the registered participants. We have coders from more than 30 countries ! With entries from Cornell, Purdue, Utah, Texas A&M, Florida, Maryland and other top Universities United States has the maximum number of participants outside India. Bangladesh, Poland, Singapore, U.K., and Canada are following US very closely in the number of teams. Rest of the countries have just a couple of teams but we have started receiving many a hits from them lately and are sure that they will catch up the aforementioned very soon.

Bitwise 2010

We even have 4 teams from Iran, and a couple teams from Vietnam, Ukraine, Uganda, Oman and Cuba. And a couple hours back we also received our first team from Kazakhstan. I was so very sure that it is spelled as Kazakhastan and had to look up wikipedia to realize my mistake !

Apart from the Ivy League colleges mentioned above, we also have algorithm enthusiasts from SPb ETU and NNSU (Russian Federation), UWe and Carcow UT (Poland), University of Lugano (Switzerland), Central University of Las Villas (Cuba), BUET (Bangladesh), NUS (Singapore), Bina Nusantara University (Indonesia), PSG and U of Edinburgh (UK), U of Helsinki (Finland), Majan College (Oman), SFU and York University (Canada), DAIICT (Australia), Sharif University of  Technology and Fferdowsi University Mashhad (Iran), MIPT (Ukraine) and the list goes on . . . [Excuse my spellings, I’ve always been poor at Geography 😦 ]

Apart from the Universities and High Schools, a large number of teams from top-notch IT organizations have also participated. Some of them are Microsoft, Cognizant Technology Solutions,  Samsung (SISO), Cisco Systems and Google. Given the huge number of participations in such a short span of time, it seems the 9th edition of Bitwise is going to be big.. really big !

We’re expecting about 5000 teams by the end of next week. And it’s going to be one hell of a job managing all the teams and their submissions on the D-day. Enigma – the precursor of Bitwise has been a huge success with participants trying out their hands at funky puzzles testing their sharpness and ability to relate some really funny pictures with computer terminologies used in day to day life. It has been so successful that there are plans to launch Enigma II on popular demand.

Thanks to our sponsors – Google, Samsung and Synopsis for shelling out money from their pockets so that we could arrange the prizes for our lucky winners.

Bitwise 2010 | IIT Kharagpur

URL: http://www.bitwise.iitkgp.ernet.in

Date: 14th February, 1200 hrs (IST)

Venue: Online

Bitwise 2K10 | IIT Kharagpur


URL: http://www.bitwise.iitkgp.ernet.in

Date: 14th February 1200 hours (IST)

Venue: Online

Bitwise is a state-of-the-art online programming contest. The contest is time constrained and posed with some of the toughest programming and algorithmic challenges in a short span of 12 hours.

Bitwise was started in the year 2001 by the 4th year undergraduate students of CSE Department, IIT Kharagpur. The contest provides programmers across the globe a platform to compete and test their abilities to develop efficient algorithms for engrossing real-life problems within a given time constraint. Over the last five years, the contest has become extremely popular around the world. In Bitwise 2k9, over 3000 teams participated from over 50 countries.

Registration is free and open to all. Contestants need to solve a set of problems posted on the site using C or C++. The solutions are evaluated, not only on the basis of correctness, but also on their execution time and space complexities.

Adding a startup script that always runs at boot time

You have a script that you need to run everytime your system boots? say, for example you need to dial up to connect to internet. Its very simple and straight forward:-

Write a script and add it to your /etc/init.d/ directory, say your script’s name is wvdial.sh

$ mv wvdial.sh /etc/init.d/
$ update-rc.d wvdial.sh defaults

that’s all… now boot your system and tada… no more typing in commands on the terminal after boot to do those daily bootup tasks!