change forgotten root password in debian squeeze

You have to change to file 

first:
nano /etc/shadow

after that you will get something like this

root:$6$MLYE3AHZ$/lEpzz820jd3n96ST1pph3kWFxUCS6hqeMUozqcy8Wo0J/GzRbzoWga9177vlX353KPBGUzWR5qsxyzEf9Zbq0:15362:0:99999:7:::

It will look like this
root::15362:0:99999:7:::

delete all between first and second colons. Then save it.

There after edit another file

nano /etc/pam.d/gdm3

In this file comment 5th line.

#%PAM-1.0
auth    requisite       pam_nologin.so
auth    required        pam_env.so readenv=1
auth    required        pam_env.so readenv=1 envfile=/etc/default/locale
#auth    required    pam_succeed_if.so user != root quiet_success
@include common-auth
auth    optional        pam_gnome_keyring.so
@include common-account
session required        pam_limits.so
@include common-session
session optional        pam_gnome_keyring.so auto_start
@include common-password

Save and reboot your machine. now you can able to login as root without password.

Set your password with following command
root@localhost:~#passwd root