Monthly Archives: August 2011

find to exclude hidden files

I needed to clean up my home account, to remove all the usual files, except for the hidden files (the various gnome/app confs/settings etc) into one directory. This is what I used:

find . -type f -maxdepth 1 ( ! -regex '.*/..*' ) -exec mv -vf {} all ;

I got the regex part from here:
http://www.linuxquestions.org/questions/linux-general-1/how-do-i-make-find-exclude-hidden-files-files-613793/

Also, later I found another one that I vent tried yet, maybe later:

http://www.linuxquestions.org/questions/linux-newbie-8/delete-regular-files-not-hidden-files-with-find-rm-in-one-line-older-than-15-a-855070/


find /home -type f -mtime +15 -not -name ".*" -exec rm {} ;

A beginners guide to git how to!

hi,

Let me first tell you what all I am going to tell you.

If you are coming from the world of svn/cvs (like me), I am going to tell you how to do git equivalent of

svn checkout ( git clone)

svn commit = (git add + git commit + git push)

What I am not going to tell you is how to setup your git account, create a new git repo etc, as the existing documentation on git is pretty good for these.

Ok, so lets begin now. I am assuming that your git account is ready, new files/folders are setup and you want to checkout your project in a new workspace.

In SVN, its a simple

svn checkout {location}

however when we try similar thing in git, we get an error!

git checkout git@github.com:anshprat/myFiles.git
fatal: Not a git repository (or any parent up to mount parent )
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

Whoops!
You see, git checkout is not like svn checkout. What git checkout does is checkout a branch or paths to the working tree.

So to do a fresh git “checkout”, you basically have to do a git clone.

git clone git@github.com:anshprat/myFiles.git
Cloning into myFiles...
Enter passphrase for key '/home/anshup/.ssh/id_rsa':
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 6 (delta 0), reused 3 (delta 0)
Receiving objects: 100% (6/6), done.

Voila! Am done.

Now how to do a git equivalent of svn commit ?

In git, this is broken down into 3 parts:

git add
git commit
git push

In svn, svn add is only for adding a new file to under revision control.
In git, git add, is useful for adding any changes to the index that would be finally merged or committed to the git repo online.

git commit : by this you are confirming that the changed files that you ve added by git add are ready to be committed.

git push: This is the command that finally pushes your changes back to the git repository!

So now you know how to do a “svn checkout and svn commit” using git :P

Look out for more as I delve more into git :)

How to enable WOL on Dell Inspiron 1420 with Fedora/Linux

I use my laptop (dell Inspiron 1420) as a server for remote access from office. Even at home, my primary laptop is my mac. I just let my dell run all the time as I don’t know when I would need/want to access that from office.

I wanted to enable WOL or Wake Up on Lan so that I could start my laptop from office if required. Even though it says “Wake Up on Lan”, it can be started from internet as well.

First place to start was to enable the WOL option in BIOS. And lo.. it wasn’t there.. ! So, does my NIC card doesn’t support WOL ?

But a quick probe using ethtool showed WOL was indeed supported on my card.

[root@mouthwa init.d]# ethtool eth0
Settings for eth0:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 100Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 1
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown
Supports Wake-on: g
Wake-on: d
Current message level: 0x000000ff (255)
Link detected: yes

Now the next line, Wake-on: d means that WOl was disabled. To enable WOL, use:

ethtool -s eth0 wol g

Now this change is not persistent, i.e, it will be gone in the next reboot.
So to make it persisten, I put a file in /etc/init.d/

cat /etc/init.d/wol
#!/bin/bash
#wake on lan
ethtool -s eth0 wol g
exit

Do a chmod +x on the file.

Now check which all devices are allowed to wake up your system in the OS:

[root@mouthwa init.d]# cat /proc/acpi/wakeup
Device S-state Status Sysfs node
PCI0 S5 *disabled no-bus:pci0000:00
PCIE S4 *disabled pci:0000:00:1e.0
USB1 S0 *disabled pci:0000:00:1d.0
USB2 S0 *disabled pci:0000:00:1d.1
USB3 S0 *disabled pci:0000:00:1d.2
USB4 S0 *disabled pci:0000:00:1a.0
USB5 S0 *disabled pci:0000:00:1a.1
EHC2 S0 *disabled pci:0000:00:1a.7
EHCI S0 *disabled pci:0000:00:1d.7
AZAL S3 *disabled pci:0000:00:1b.0
RP01 S3 *disabled pci:0000:00:1c.0
RP02 S3 *disabled pci:0000:00:1c.1
RP03 S3 *disabled
RP04 S3 *disabled pci:0000:00:1c.3
RP05 S3 *disabled
RP06 S5 *disabled pci:0000:00:1c.5
LID S3 *enabled
PBTN S4 *enabled
MBTN S5 *disabled

I need to find out which of the above is my NIC card and enable wake up for that.

[root@mouthwa init.d]# lspci -tv
-[0000:00]-+-00.0 Intel Corporation Mobile PM965/GM965/GL960 Memory Controller Hub
+-01.0-[01]—-00.0 nVidia Corporation G86 [GeForce 8400M GS]
+-1a.0 Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #4
+-1a.1 Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #5
+-1a.7 Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #2
+-1b.0 Intel Corporation 82801H (ICH8 Family) HD Audio Controller
+-1c.0-[0b]–
+-1c.1-[0c]—-00.0 Intel Corporation PRO/Wireless 3945ABG [Golan] Network Connection
+-1c.3-[0d-0e]–
+-1c.5-[09]—-00.0 Broadcom Corporation NetLink BCM5906M Fast Ethernet PCI Express
+-1d.0 Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #1
+-1d.1 Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #2
+-1d.2 Intel Corporation 82801H (ICH8 Family) USB UHCI Controller #3
+-1d.7 Intel Corporation 82801H (ICH8 Family) USB2 EHCI Controller #1
+-1e.0-[03]–+-01.0 Ricoh Co Ltd R5C832 IEEE 1394 Controller
| +-01.1 Ricoh Co Ltd R5C822 SD/SDIO/MMC/MS/MSPro Host Adapter
| +-01.2 Ricoh Co Ltd R5C592 Memory Stick Bus Host Adapter
| -01.3 Ricoh Co Ltd xD-Picture Card Controller
+-1f.0 Intel Corporation 82801HEM (ICH8M) LPC Interface Controller
+-1f.1 Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) IDE Controller
+-1f.2 Intel Corporation 82801HBM/HEM (ICH8M/ICH8M-E) SATA AHCI Controller
-1f.3 Intel Corporation 82801H (ICH8 Family) SMBus Controller

Notice the 1c.5 in front of my LAN card in the lspci output above. Look for the same number in the /proc/acpi/wakeup and I find that my card is RPC06!

Now to enable the wakeup for my card, a simple echo will do:


[root@mouthwa init.d]# echo RP06>/proc/acpi/wakeup
[root@mouthwa init.d]# cat /proc/acpi/wakeup |grep RP06
RP06 S5 *enabled pci:0000:00:1c.5

So there you are, WOL is enabled!
However, it can wake up only from certain states, not all at the moment.

So, the best way to switch off the laptop so that it can be woken from LAN is

[root@mouthwa init.d]# pm-suspend-hybrid

What it does is that the system does everything it needs to hibernate, but suspends instead of shutting down. This means that your computer can wake up quicker than for
normal hibernation if you do not run out of power, and you can resume even if you run out of power.
Most of the above was sourced from here.

Now, the script to wake up from internet.

I got it from here:

http://www.hackernotcracker.com/2006-04/wol-wake-on-lan-tutorial-with-bonus-php-script.html

Also, If you dont want to or dont have a place to run scripts, you can use online services like:

http://www.depicus.com/wake-on-lan/woli.aspx

Ofcourse, you need to know your MAC address, your router address and the subnet.
Keep subnet as 255.255.255.255 in the depicus page if you have one public ip and the router allots private ips using DHCP. (This is true for most of the routers).

And now, I can happily power down my laptop and wake it up when required! #FTW

WordPress security update – password change and discount coupon

Just got this mail from wordpress asking me to change my password. They also offered a 15% discount on their services as a Sorry coupon.. :!

I just wonder how many accounts were affected and what was the exact issue. Hope it wasn’t saved in cleartext!

And yes, its a legit email. Just be careful that the link you get finally ends up in https://wordpress.com.

Also, it doesn’t ask you to enter your old password but just new password.

Well, I ve changed my password here, but where else is it? Thankfully its one of my lesser used password..

WordPress.com ✆ passwordcoupon@wordpress.com to me

show details 4:43 AM (1 hour ago)

Hello h4ck@lyst,

We recently found and fixed a mistake that we’d like to tell you about. Passwords on WordPress.com are saved in a way that makes them extremely secure, such that even our own employees are unable to see your actual password – the one you enter to login to your WordPress.com account. However, between July 2007 and April 2008, and September 2010 and July 2011, a mistake in one of our systems used to find and correct bugs on WordPress.com accidentally logged some users’ passwords in a less secure format during registration.

We’ve updated our systems to prevent passwords from being logged this way in the future, so this will not happen again. We don’t have any evidence that this data has been accessed maliciously or misused, but to be on the safe side we are resetting your password since your account is among those affected.

Please change your password using this link or copy and paste the URL below into your web browser:

https://wordpress.com/wp-login.php?action=rp&key={key}&login={myUserId}

If the password you used when you registered on WordPress.com was one you use elsewhere, you should change it there, too. In the future, remember that it’s good practice to always use unique passwords for different services.

We are terribly sorry about this mistake. No one likes having to create new passwords and we’d like to include a 15% off coupon to say we’re sorry. The coupon can be used for a custom domain, a design upgrade, VideoPress, or a storage space increase. Just use the code below on any of the upgrades on the WordPress.com Store:

{myCOde}

If you have any questions, please reply to this email and one of our Happiness Engineers will get back to you as soon as possible.

Thank you,
The WordPress.com Team

WordPress

WordPress.com | Thanks for flying with WordPress!

Vodafone 3g call woes – Solved!

This blog post is about my recent switch to Vodafone 3G and related experience. Or just related woes. Experience hasn’t been much yet.

Vodafone finally launched 3G in bangalore (I think using Airtel infrastructure).

I had tested BSNL 3G earlier (pretty good) but wasn’t ready to make a permanent switch to BSNL (number woes despite MNP). Also am quiet satisfied with Vodafone phone services.

Anyways, after I moved to 3G, I suffered a drastic setback. My calls wont be connected! Not dropped connections, but calls simply wont be connected. After I dial a number, it would just hang up in a matter of minutes. Everytime I would ve to reselect the Operator from the network menu. And somehow, the menu would always show two vodafone (and NO Airtel at all!).

I ve an android phone. And there was no simple way to select manual selection of operator explicitly ( I do miss the good old days of not so smartphones at times!).

I did tweet about my woes and VodafoneIN replied with a complaint number.

And on the sidelines, I found the solution, by mistake..

I selected “Use only 2G Network” and voila! All my calls were being connected at ease like before!

Guess this demonstrates the fact that Vodafone uses 3G using airtel network and since airtel becomes the preferred network, the outgoing calls have some issues.

Will debug more on this later in the week.

Blogging from mobile

I am kinda late to the mobile blogging scene, owing to slow gprs speed, missing 3g connection and a mobile device with wifi connection (well I had the ipad for about 6 months now but guess I was lazy). So now that I ve 3g on my nexus s (not to forget wifi on it as well) , I ve now installed WordPress for android on it. I can immediately see the pros n cons of it. Pros – blogging on the move.  Cons – the linking to other pages etc would be more cumbersome as you can’t just open a tab, copy a link and paste. A big major pros is the auto suggest and auto correct that you get on all mobile phones. Well… I guess am gonna be happy about it…

UPDATE: I opened the post in my laptop browser to add the android marketplaces link. Guess, mobile blogging will take sometime before its my first choice. I ll try it from my ipad as well. Somehow it appears as if thats gonna be more intuitive.

How to stop auto selection of preferred network operator in android or set manual operator selection.

I was hunting for this question for the past few days, ever since I enabled 3G on my nexus S vodafone connection. The phone would use auto PRL (preferred Roaming List) to switch over the network with better connection. In my case I was getting two vodafone networks. While I could always receive calls and messages, I could never send a message or make a call unless I reselected the other network.

To avoid this, and cases like these , you need to switch off automatically select prefereed network.

The way to do this is

dial *#*#4636#*#*

click Phone Info -> Set preferred network type -> GSM only (or CDMA if you are using CDMA).

The important thing here is not to use any auto or PRL settings.

And voila, now your android phone will only use manual network operator, just like the golden times…

And I ve moved, again..

And its time again for the next @indiblogger meetup.

And this meetup prompted me to get my blog up and running again :P I ve moved from slicehost to the parent company rackspace owing to

  • lesser cost
  • Upcoming ipv6 support

Even though slicehost itself is about to integrate into the rackspace infrastructure, meaning slicehost will be moving to rackspace cloud and will be charging similar prices, I, as always, being impatient couldn’t wait and moved :P

 

I guess the downside of that being that I had to manually move and setup everything myself. Vs maybe slicehost and rackspace would ve provided moving support had I waited for them :P

 

but anyways, its the next @indiblogger meetup about the samsung galaxy tab that has got me interested in blogging again. I ve my exams in the next week and I woke up this morning with intent to read, but I took the wrong step of opening up twitter. One thing lead to another and here I am blogging. But considering that the entire thing happened in less than two hours, I think it was a pretty efficient usage of time. Time to get ready for office, and then back and then try to study and blog and tweet and all as usual :)

Good thing be that grandmom aka amma is here now. So I dont ve to worry about dining plans :)

PS: There is a new domain as well, hackalyst.info. Right now anshprat.info and hackalyst.info both point to the same site. Maybe I ll merge, maybe I ll let it be.

And the new site is called muddle-muggle. Muddle – coz of the ever presence confusion. Muggle – coz I wish I was a wizard, or atleast had some super powers :P