DEHRADUN — An earthquake of magnitude of 5.1 on the Richter scale rocked several parts of Uttarakhand early Thursday, an official said.