Monday, February 28, 2011
Sunday, February 27, 2011
A worthy candidate for my desktop wallpaper.
Tuesday, February 22, 2011
kill a non responsive process
So what do you do when you a process running on your Linux box hangs? Obviously you terminate it and start it again. But how do you terminate it is the question - series of commands or few clicks in System Monitor?
Frankly this post is for those who use the terminal - the "geeks".
Until today I used to kill programs "in this case" like
$ ps -e | grep firefox
which gave me output like
2472 ? 00:00:00 firefox 2480 ? 07:16:45 firefox-bin
$ kill 2472 2480to terminate the programs.
But today it just occurred to me to automate the process of looking up the process number and killing them. So I set out to use gawk and xargs.
Using gawk I got the process numbers extracted from the output of grep like this:-
$ ps -e | grep firefox | gawk '{print $1}'
2472
2480
and then pipelined this output to xargs kill to invoke kill on each pid.$ ps -e | grep firefox | gawk '{print $1}' |xargs kill
It kills two processes but for completely restarting the application go to a terminal and type$ ps -e | grep firefox | gawk '{print $1}' |xargs kill; firefox &
$ firefox & # starts firefox in the back groundThis served my purpose. Terminating two processes manually is not a big task, but why not automate it and make the computer do it for you if its possible?
And don't forget to have a look at man pages of gawk xargs and grep because that is the ultimate source of knowledge :)
Saturday, February 19, 2011
calculate 5000th fibonacci number
This year programming competition in tech-fest at college, was organised by the friend with whom I team up for participating in competitions of other colleges. It was obviously better than previous years. I mean,questions were good, had considerable participants and most importantly, programming was supposed to be done using gcc/g++/java.
There was a question which asked to print the n^th term of Fibonacci series where 0<=n<=5000. Frankly such a large number does not fit in whatever predefined data type you can think of. Creating something like BigInteger of java would have been impossible during the competition and I am not an expert when it comes to java, so I skipped the problem. The coordinators accepted solution for 20 to 30 terms from other teams but demanded it for 5000 from me :P (being famous has its drawbacks !!!). Still I concentrated on other problems (got through this one but couldn't go to the finals because its timing clashed with another one :( ).
Later that night, after the competition was over, one of the coordinators pinged me on gtalk and asked sarcastically for the solution. This got on my nerves and I determined that I will smack the 5000th element on their face.
There was a bigint library I had created about an year ago which stored numbers in character arrays and manipulated them. I shuffled through my code directory, found it and quickly created a recursive function using memorisation to serve the purpose. The problem was that it worked fine for inputs upto 1302 but gave a segmentation fault for numbers above that. Puzzled and perplexed I resorted to Internet search and discovered that it was because of default stack size of 1MB allocated to every process. A few minutes later I stumbled upon the solution to increasing it which was as simple as adding
ulimit -s unlimited
to
/home/<user_name>/.bashrc
file and starting a new session. This increased the stack size to unlimited i.e now my program could use all the RAM available.
After this was done, my program successfully calculated and printed the sequence upto 7000 but ran out of RAM after this and gave Bus Error.
I redirected the output of the program to a text file, attached it to a mail and sent it to the coordinators ;)
Here is a screenshot showing a terminal window with the 7000th Fibonacci number and the state of my system while calculating it.

P.S: The code for my program is hosted at www.github.com/bhanuvrat/bigint .
Tuesday, June 29, 2010
misusing transport technology
I have just had the worst travelling experience on my way back from Patna to Dhanbad. In a compartment meant to accommodate 8 there were at least 20-25 people stuffed like pigs and hens. Although I had a berth reserved for me, it was occupied by 5 other people. And these were not the ones with a wait-listed Sleeper ticket that did not get confirmed, they were the ones supposed to be travelling in Second Seater. The situation was worsened by the hot and humid climate. "We Indians are hairy people, we perspire a lot and then stink" - Russel Peters. Its not like I haven't travelled in DTC busses, but that is for at most 2 hours while this was a 9 hour journey ( took 11 - courtsey highly unpunctual Indian Railways). I developed sympathy for the British people whom I hated for kicking Indians out of railway carriages during British Raj, because I was feeling a similar urge. Until 12 there was no sign of any TT, and upon inquiring we came to know about incidences when these so called "daily passengers" had pushed the Ticket Checker out of running train.
All we so called tech-literates complain about is slow speed of Internet and interrupted power supply while there are people who still travel like slaves, and the middle class people are not able to travel comfortably despite having paid for it. Indian Railways boasts off about being the only successful public sector railways! But I want to ask the authorities, what do they want me to be proud of? The stinking platforms of Old Delhi where all you can see is shit on tracks or the utterly comfortable journey that I just had?
All we so called tech-literates complain about is slow speed of Internet and interrupted power supply while there are people who still travel like slaves, and the middle class people are not able to travel comfortably despite having paid for it. Indian Railways boasts off about being the only successful public sector railways! But I want to ask the authorities, what do they want me to be proud of? The stinking platforms of Old Delhi where all you can see is shit on tracks or the utterly comfortable journey that I just had?
Thursday, May 27, 2010
FC13 : solution to apparently all problems.
Yesterday I came across a tweet which said Fedora core 13 has been released. I have been using FC12 for over a month now and hence was excited about FC13. Although I am on the verge of crossing the data limit of my internet connection, I downloaded the live CD and gave it a try. I was astonished by my findings.
FC13 has done away with most of my problems.
I am merrily downloading the Installer DVD, can't wait for tech-magazines to ship it with them. I think most of the major distributions coming out now will be able to include the required drivers and hence work out of the box on my DELL. So in case you've been facing problems with your new laptop whose hardware was not supported by the contemporary distros, its time to switch over to Fedora Core 13
FC13 has done away with most of my problems.
- ACPI problem on Dell Studio 14 - solved.
- No Sound - driver missing - was already solved.
- Graphics driver:- mesa-drivers included in FC13 are fully compatible with my ATI Radeon 4530. I was frantically posting on forums for this post1 post
- Unable to stream Video on firefox - still persists :(
I am merrily downloading the Installer DVD, can't wait for tech-magazines to ship it with them. I think most of the major distributions coming out now will be able to include the required drivers and hence work out of the box on my DELL. So in case you've been facing problems with your new laptop whose hardware was not supported by the contemporary distros, its time to switch over to Fedora Core 13
Solved the no sound problem on my dell :)
It was right on Day one that I formatted my new Laptop's hard drive to create partitions on it and install Linux. Well that was in fact a failure because of the ACPI problem. But after I came to know about acpi=off work around I managed to install linux and then the most torturing problem on my system was absence of sound. I nearly spent the whole next week trying to figure out (rather google out) the solution. But it was not there. It was just day before yesterday that I stumbled upon the solution.
The problem was :
There was no sound from the inbuilt speakers, and one of the two jacks worked but produced sound which was barely audible. I lingered over forums for a very long time - meanwhile switched and tried different distros .. hoping one of them might come with a solution by default.
Attempts made by me to solve it:
Most of the times when I looked into search results that said "solved", what I found was "the audio channel was muted". I also found posts that asked me to modify the modprobe.conf and add dell-m6 after intel-hda-snd etc. but none of them worked ... in fact I found a complete list of such options that could be appended on to the modprobe.conf file and tried every one of them that was related to dell.
Recently After installing Arch Linux I came across OSS - Open Sound System and installed it instead of ALSA.. it seemed to work but I couldn't figure out how to mute the speakers while using head phones. I was determined to look for the solution in the same direction.
Solution:
The way to get it to work is to install the new version of alsa ( god why couldn't I think of it .. argh). For obtaining it follow the ***link*** to realtek's site. This is the genius post which brought me closer to the solution. And this is where I was spoon fed with it.
I am loving it :)
The problem was :
There was no sound from the inbuilt speakers, and one of the two jacks worked but produced sound which was barely audible. I lingered over forums for a very long time - meanwhile switched and tried different distros .. hoping one of them might come with a solution by default.
Attempts made by me to solve it:
Most of the times when I looked into search results that said "solved", what I found was "the audio channel was muted". I also found posts that asked me to modify the modprobe.conf and add dell-m6 after intel-hda-snd etc. but none of them worked ... in fact I found a complete list of such options that could be appended on to the modprobe.conf file and tried every one of them that was related to dell.
Recently After installing Arch Linux I came across OSS - Open Sound System and installed it instead of ALSA.. it seemed to work but I couldn't figure out how to mute the speakers while using head phones. I was determined to look for the solution in the same direction.
Solution:
The way to get it to work is to install the new version of alsa ( god why couldn't I think of it .. argh). For obtaining it follow the ***link*** to realtek's site. This is the genius post which brought me closer to the solution. And this is where I was spoon fed with it.
I am loving it :)
Friday, April 30, 2010
Linux... Ye hi hai right choice
We come across various articles, blog posts and speeches in which the people supporting open source advocate about its benefits and try to attract more and more people into the brotherhood.
Being a Linux enthusiast I felt my responsibility do some thing of the same kind to spread the word a bit more.
If we think about it then the first question popping up in our fleshy brains would be what exactly is the crap called OPEN SOURCE? Many people have a misconception that all the softwares that we can download and use (legally) for free some how defines OPEN SOURCE. So lemme tell you that this is just a small aspect of the tech movement. Open source means that the source of the software is available for free and that you are allowed to modify it as per your wish or needs.
The second question would be ... Why the heck would some one make whole of his hard work available for free? How would the person or the company make profit out of it? And if there is no profit involved .. why are the people working? The answer is, its not the software but the support that is sold. Big Open Source players pay their employees with the money they get through the customer support they offer and donation they get.
So this fairly leaves the pockets of home users unaltered. The corporate people, however, have to pay for the support but this is near about to nothing when compared to the cost of lisence for using proprietary software.
For more information one can surely go and visit these pages :
http://en.wikipedia.org/wiki/Open_source
http://www.opensource.org/
http://www.gnu.org/
http://en.wikipedia.org/wiki/Linux
As there are infinitely many linux distributions, a first time user is bound to get confused over choosing the BEST linux distribution for him/her self. So here is a presentation that i gave quite a few months ago as one of the OSUM sessions. :- link to google slide show
Being a Linux enthusiast I felt my responsibility do some thing of the same kind to spread the word a bit more.
If we think about it then the first question popping up in our fleshy brains would be what exactly is the crap called OPEN SOURCE? Many people have a misconception that all the softwares that we can download and use (legally) for free some how defines OPEN SOURCE. So lemme tell you that this is just a small aspect of the tech movement. Open source means that the source of the software is available for free and that you are allowed to modify it as per your wish or needs.
The second question would be ... Why the heck would some one make whole of his hard work available for free? How would the person or the company make profit out of it? And if there is no profit involved .. why are the people working? The answer is, its not the software but the support that is sold. Big Open Source players pay their employees with the money they get through the customer support they offer and donation they get.
So this fairly leaves the pockets of home users unaltered. The corporate people, however, have to pay for the support but this is near about to nothing when compared to the cost of lisence for using proprietary software.
For more information one can surely go and visit these pages :
http://en.wikipedia.org/wiki/Open_source
http://www.opensource.org/
http://www.gnu.org/
http://en.wikipedia.org/wiki/Linux
As there are infinitely many linux distributions, a first time user is bound to get confused over choosing the BEST linux distribution for him/her self. So here is a presentation that i gave quite a few months ago as one of the OSUM sessions. :- link to google slide show
Friday, April 9, 2010
Problematic ACPI on new Dell Studio 1450 laptop
The Wipro Laptop had seen its good days, but its keypad went wrong (worked fine at night, and in the morning it was screwed up) and started displaying two characters upon one key press, its lan port and memory card slot wouldn't ever work, its CD/DVD drive would get screwed up every 2 months and most recently its screen cracked ( dunno how it happened) and a vertical white line hid two characters behind it in text mode and equivalent area in graphics mode). The width of this white line was going on increasing and presently it covers area equivalent to 2 characters in text mode. These developments ( -ve sense) pushed me to get a new laptop for myself and this time I decided not to make the mistakes I had made the last time. I went for a Dell Studio 1450 laptop.
Specifications:
Intel Centrino Core 2 Duo 2.26 ghz 1066 mhz, 3MB cache
4GB RAM
500 GB SATA HDD
512 MB ATI Mobility Radeon 4530
The ACPI problem:
Its on this new laptop that I am facing a problem with Linux OSs. However Windows 7 that was shipped with the machine works fine. Initially i wasn't even able to boot into a live installer CD. During booting (into a live CD or hard drive) the screen would go blank right after loading ACPI module and the computer would not respond to anything including Ctrl+Alt+Del, the only option left out would be hardware power off. I went around on forums (my linuxquestions.org post) begging for help but ultimately it was a teenage linux magazine columnist (Shashwat Pant) who helped me out on gtalk. The solution was to append acpi=off as a kernel parameter in grub. This got linux up and running on my laptop but was not a permanent remedy. acpi=off ended up disabling a lot of options eg - battery was not recognized, function keys behaved in the opposite manner etc. It also caused power button to function as the ones on computers of 90s - i.e when pressed, the laptop would not ask for what is to be done rather it would get switched off ( without the process of shutdown - or holding the power button for a while) right away. And the computer had to be switched off manually even after choosing shutdown from the power menu. Here is the link to the forum I used for all my problems till then.
Attempts to resolve it:
On OpenSUSE, just for fun and learning, I compiled and installed linux kernel 2.6.32 and to my surprise the acpi problem had vanished :). However there were other problems that I had been facing on it (specifically - installing the graphics driver caused display - dragging windows or scrolling text all were jerky and without the driver compiz fusion won't work :( ). And in the process of trying to solve the graphics problem I screwed up OpenSUSE. Arch Linux seemed to be attractive enough and I reckoned that installing every thing one by one on my own might help me recognize the root cause of problems. However the new kernel trick didn't work on Arch, and I was again chasing the same problem. (My post on arch forum.)
I found that while compiling the kernel, the ACPI module can either be compiled into it or as a separate module to be loaded later. I tried both ways and what I found was really demoralizing. Without the acpi=off option the OS behaved quite randomly i.e sometimes it would boot fine and sometimes not. I also tried compile the kernel after disabling those options (in the menuconfig's submenu about acpi) which had deprecated mentioned beside them, with no luck. (i.e not specifying acpi=off causes the same problem that it used to cause initially, irrespective of the options I choose while compiling the kernel).
Recent Development
Today I found that the computer does not hang !!. its just that the screen goes off if I do not specify the acpi=off option. That is while it is booting, the screen goes off right after loading the acpi module but the boot process continues. I knew that after booting the arch installation ( which presently has no graphical desktop environment) prompts me for id and password. Although it was not visible, I keyed in my id and password and then fired reboot command ---- and --- the computer rebooted !!!.
I have not lost hope and am still pursuing the ghastly outline of solution. Any kind of help is welcome !!
Specifications:
Intel Centrino Core 2 Duo 2.26 ghz 1066 mhz, 3MB cache
4GB RAM
500 GB SATA HDD
512 MB ATI Mobility Radeon 4530
The ACPI problem:
Its on this new laptop that I am facing a problem with Linux OSs. However Windows 7 that was shipped with the machine works fine. Initially i wasn't even able to boot into a live installer CD. During booting (into a live CD or hard drive) the screen would go blank right after loading ACPI module and the computer would not respond to anything including Ctrl+Alt+Del, the only option left out would be hardware power off. I went around on forums (my linuxquestions.org post) begging for help but ultimately it was a teenage linux magazine columnist (Shashwat Pant) who helped me out on gtalk. The solution was to append acpi=off as a kernel parameter in grub. This got linux up and running on my laptop but was not a permanent remedy. acpi=off ended up disabling a lot of options eg - battery was not recognized, function keys behaved in the opposite manner etc. It also caused power button to function as the ones on computers of 90s - i.e when pressed, the laptop would not ask for what is to be done rather it would get switched off ( without the process of shutdown - or holding the power button for a while) right away. And the computer had to be switched off manually even after choosing shutdown from the power menu. Here is the link to the forum I used for all my problems till then.
Attempts to resolve it:
On OpenSUSE, just for fun and learning, I compiled and installed linux kernel 2.6.32 and to my surprise the acpi problem had vanished :). However there were other problems that I had been facing on it (specifically - installing the graphics driver caused display - dragging windows or scrolling text all were jerky and without the driver compiz fusion won't work :( ). And in the process of trying to solve the graphics problem I screwed up OpenSUSE. Arch Linux seemed to be attractive enough and I reckoned that installing every thing one by one on my own might help me recognize the root cause of problems. However the new kernel trick didn't work on Arch, and I was again chasing the same problem. (My post on arch forum.)
I found that while compiling the kernel, the ACPI module can either be compiled into it or as a separate module to be loaded later. I tried both ways and what I found was really demoralizing. Without the acpi=off option the OS behaved quite randomly i.e sometimes it would boot fine and sometimes not. I also tried compile the kernel after disabling those options (in the menuconfig's submenu about acpi) which had deprecated mentioned beside them, with no luck. (i.e not specifying acpi=off causes the same problem that it used to cause initially, irrespective of the options I choose while compiling the kernel).
Recent Development
Today I found that the computer does not hang !!. its just that the screen goes off if I do not specify the acpi=off option. That is while it is booting, the screen goes off right after loading the acpi module but the boot process continues. I knew that after booting the arch installation ( which presently has no graphical desktop environment) prompts me for id and password. Although it was not visible, I keyed in my id and password and then fired reboot command ---- and --- the computer rebooted !!!.
I have not lost hope and am still pursuing the ghastly outline of solution. Any kind of help is welcome !!
Thursday, April 8, 2010
links - text based web browser
It was around midnight, that my room-mate (who is a budding linux geek) saw me downloading kernel files using wget from a terminal without the help of any kind of grahpical web browser. Then we wondered, how cool it would be if we could use a text based web-browser for our general work like checking mail, facebook status, attendance over college's intranet etc. I reckoned, it would be quite fast too because no imager or flash ads would be downloaded.
A few hours later I had accomplished installing xfce4 desktop manager on Arch Linux and was fiddling around with its features (which were nothing except a text editor, a terminal emulator and few configuration utilities). Just then a shortcut for a web-browser caught my eye and I couldn't recall having installed pacakges of firefox or anything. Out of curiosity I clicked it open and bang a terminal window opened up !!! there it was !! I had discovered a text based web-browser !!!
Little bit of fooling around got me familiar with its UI which is nothing except a few menus that emerge when escape key is pressed. I opened google.com (dunno why but google.com is what comes to mind even when what I want to do is just check internet connectivity). There was no limit of his excitement when I introduced Abhinandan to my marvellous discovery. Together we tried exploring a lot of sites on it. It was a new kind of experience looking at the usual web content in text mode. We searched wikipedia for the creator of "links" and checked our gmail accounts. However the intranet utility of our university wouldn't let us log in ( a few months ago we could't log in even from mozilla - only IE was supported :P so no worries). Regular facebook didn't show up properly, however m.facebook.com which is its mobile version, was wonderful, I updated my status and checked notifications.
Then my room-mate suggested how about downloading something .. so we opened an ftp site and pressed enter (which was equivalent to clicking there) on a link. A pop up menu appeared asking what I would like to do with the file ( display or a save). Actually display option opened any file in text mode and displayed its contents - which wasn't something I wanted. Upon choosing save, another popup window appeared which displayed the progress of download. This one even contained an option for continuing the download in background which seemed to be quite useful for this kind of a browser.
And now here I am writing a blog post at about 6 AM using the same geeky browser.
Its not a very impressive but is quite wonderful (atleast for a comp-geek who had never seen something similar). Links sports a download manager, bookmark manager, short history, and a very helpful user's manual:). It can come quite handy when we need to access internet while fixing up something on our linux box. For example I was using my other laptop for accessing the arch linux install guide for installing the distro and now I won't need to. I can visit forums, check facebook status, mail, search for stuff even when I am fiddling around with the OS or am trying to get it back on after screwing it up ;)
A few hours later I had accomplished installing xfce4 desktop manager on Arch Linux and was fiddling around with its features (which were nothing except a text editor, a terminal emulator and few configuration utilities). Just then a shortcut for a web-browser caught my eye and I couldn't recall having installed pacakges of firefox or anything. Out of curiosity I clicked it open and bang a terminal window opened up !!! there it was !! I had discovered a text based web-browser !!!
Little bit of fooling around got me familiar with its UI which is nothing except a few menus that emerge when escape key is pressed. I opened google.com (dunno why but google.com is what comes to mind even when what I want to do is just check internet connectivity). There was no limit of his excitement when I introduced Abhinandan to my marvellous discovery. Together we tried exploring a lot of sites on it. It was a new kind of experience looking at the usual web content in text mode. We searched wikipedia for the creator of "links" and checked our gmail accounts. However the intranet utility of our university wouldn't let us log in ( a few months ago we could't log in even from mozilla - only IE was supported :P so no worries). Regular facebook didn't show up properly, however m.facebook.com which is its mobile version, was wonderful, I updated my status and checked notifications.
Then my room-mate suggested how about downloading something .. so we opened an ftp site and pressed enter (which was equivalent to clicking there) on a link. A pop up menu appeared asking what I would like to do with the file ( display or a save). Actually display option opened any file in text mode and displayed its contents - which wasn't something I wanted. Upon choosing save, another popup window appeared which displayed the progress of download. This one even contained an option for continuing the download in background which seemed to be quite useful for this kind of a browser.
And now here I am writing a blog post at about 6 AM using the same geeky browser.
Its not a very impressive but is quite wonderful (atleast for a comp-geek who had never seen something similar). Links sports a download manager, bookmark manager, short history, and a very helpful user's manual:). It can come quite handy when we need to access internet while fixing up something on our linux box. For example I was using my other laptop for accessing the arch linux install guide for installing the distro and now I won't need to. I can visit forums, check facebook status, mail, search for stuff even when I am fiddling around with the OS or am trying to get it back on after screwing it up ;)
Subscribe to:
Comments (Atom)