Thursday, May 28, 2009

Recover deleted files from deleted partition

I never thought recovering files would be so easy. I had deleted my personal files on old Laptop to return it.
I also repartitioned the disk using the Ubuntu install CD.

But I later realized later that I had deleted something that I had not backed up(so naive).

There are two Linux tools that I found useful.
1) testdisk
2) photorec

There is a project called SystemRescueCd which includes useful tools to recover data.

I used "test disk" tool to recover the deleted partition I was not able to restore the partition as such. But was able to browse files using the tool itself.

There is another tool called  "photorec" which I used to recover deleted files of that partition.

you can use the SystemRescueCd bootable cd or boot using ubuntu live cd and install the tools you want and use them as I did.
Blogged with the Flock Browser

Thursday, May 7, 2009

analyze extremely large packet capture(tcpdump) file

I recently had to analyze an extremely large packet capture file to resolve a customer issue.
wireshark would crash trying to load the file(around 375 MB).
You start thinking 'why did the client not capture packets only when the problem occured?'.
But, I quickly realised that tcpdump can be used with the capture file as input and filters can be applied to extract packets of our interest.

In this case I was interested in packets that had a particular ip address. So used the below command to extracted those packets into another pcap file.

tcpdump -r [largefile.pcap] -w [filteredFile.pcap] [filter]

And now I have a pcap file that wireshark can load so that I can take a good look at what is happening.

Wednesday, September 17, 2008

The state of the internet reports from akamai

Akamai is publishing quarterly report on the internet called "The state of the internet"
These reports can be found here http://www.akamai.com/stateoftheinternet/
It can be downloaded after quick registration.

The reports give interesting insights into how internet works.

interesting things I found, relating to india:

1) Reliance Globalcom is a big player in cable connectivity
sinip--
"In April 2008, Reliance Globalcom used satellite imagery to identify two ships that were in
the area of the original cable cuts, and that had improperly dropped anchor in the area.18
The owners of one of the ships paid $60,000 in damages to compensate for repairs, while
the second ship was impounded in Dubai."

2) Some good things happening for india
snip--
"A consortium of 16 telecommunications firms has contracted to build a 15,000 km
submarine cable system linking India with Europe via the Middle East. The Europe India
Gateway (EIG) will cost $700 million and add 3.84 Tbps of capacity. The EIG consortium
includes firms from the US, Europe, Africa, the Middle East and India – including AT&T,
Verizon, BT, Cable & Wireless, MTN, Telecom Egypt, Omantel, Saudi Telecom Company,
du, Bharti Airtel, Gibraltar’s Gibtelecom, PT Comunicacoes of Portugal, Djibouti Telecom,
Maroc Telecom, Libya Telecom and Technology, and Telkom South Africa. Initial landings
are for the cable are planned for the UK, Portugal, Gibraltar, Morocco, Monaco, France,
Libya, Egypt, Saudi Arabia, Djibouti, Oman, the United Arab Emirates, and India.

At least two other new cables serving much the same route as the EIG are also currently

being planned. Tata Communications is leading the consortium behind the IMeWe
system, due to add another potential 3.84 Tbps to the route when it goes live in 2009.
Also backing IMeWe are Etisalat, France Telecom, Ogero of Lebanon, PTCL of Pakistan,
TIS Sparkle of Italy, as well as EIG investors Bharti Airtel, Telecom Egypt and STC. Tata is
also behind the TGN Eurasia Cable System, set to link Mumbai with Paris, London and
Madrid via Egypt, with Seacom and Telecom Egypt as fellow sponsors.36
Along these lines, research firm Telegeography’s annual Global Bandwidth Research
Service noted that 25 new submarine cables will be built over the next three years"

Tuesday, August 19, 2008

Download youtube videos using clive

How do you download youtube videos onto your computer? Do you use those web sites to do it?
There is a smarter way of doing it.
The clive command. It is available for Linux. Not sure about windows.
If you are on ubuntu life is easier... 'sudo apt-get install clive' will install clive.

downloading a video is as easy as typing the command,
$clive 'http://www.youtube.com/watch?v=sOpCfIRA9MY'

Do quote the url, it may have special characters that the shell interprets.

Read the man page for more details.
The feature that I liked is the ability to download multiple videos....

put all video links in a file, ex: videos.list then,
$cat videos.list | clive

Monday, July 28, 2008

flip characters upside down - unicode trick

You ca get your sentences flipped using this link
http://www.revfad.com/flip.html

This a simple Unicode trick. view the page source of the above link, you can find a table that maps the usual characters to their flipped versions.

Wednesday, July 9, 2008

Image magic with ImageMagick

There are various graphical tools available for manipulating images. but Imagine doing this using command line. sounds geeky !
This can be useful when you want to perform the same action on large number of images. think about reducing the size/quality of 100's of images captured on your digital camera so that you can upload them to the internet, or email them.

ImageMagick is a collection of tools that can help you do this.
You can download it from http://www.imagemagick.org/script/index.php . On ubuntu install it by typing "sudo apt-get install imagemagick"
"man imagemagick" for man page of imagemagick.
You can also look at the man page of individual tools for more detailed information

Useful Links:
--------------
Imagemagick page:
http://www.imagemagick.org/script/index.php

found this page particularly useful.
http://www.imagemagick.org/Usage/

quick start to reduce image sizes:
http://www.linuxforums.org/forum/suse-linux-help/39848-how-reduce-jpeg-file-size-email.html

Monday, June 2, 2008

Clip, cut, split mp3 files using dd

I accidentally discovered a wonderful use of the dd command on ubuntu.

clip mp3 files.

It looks like mp3 format does not have any header or footer. So copying some contiguous bytes from somewhere in the file seems to create another valid mp3 file. WOW!

I have a large mp3 ("041-oru maalai.mp3") file(song) but I feel a part of it sounds good as a ring tone for my mobile phone. I want to skip the initial music and start from the lyrics. And also cut the song and make it smaller.

The below command does it.
dd if="041-oru maalai.mp3" of="041-oru maalai_small.mp3" count=6000 skip=900

count says how many blocks to copy.
skip says how many blocks to skip form the beginning of the file.
see man page for block sizes.

now "041-oru maalai_small.mp3" is what I need.

Given this, you can do a lot of stuff.
Possibilities are limited only by your imagination.
for example, you can clip a few file and cat them to form a single music file... WOW!