Can I do this in Linux?

pitupepito2000

Golden Member
Aug 2, 2002
1,181
0
0
Hi,

As many of us I am in dead week (week before finals) and I can't keep myself away from the computer :sun: I was thinking about changing my password and closing my eyes and typing something random I wouldn't remember so I could lock myself out of my debian box. But since I am the admin I have the root password and I can very easily talk myself into changing my password back so I can use the computer for recreation rather than studying for finals. My questions is: can I change my root password to something that I wouldn't remember and then reset the password without knowing the old password. Kind of like getting back to root without a password. Can I do this by chrooting to the hard drive using? I don't know if this is possible? I am just trying to get myself out of the computer for two weeks until finals are over. Then I can get my passwords back.

Please help this poor undergraduate student,
my grades thank you,
pitupepito
 

djdrastic

Senior member
Dec 4, 2002
441
0
0
Well I've done it with my FreeBSD Box , there should be a way to get Debian Up . Will look 4 solution

1)Boot into Single User Mode
2)Mount root file system in mnt - You should mount it in R/W Mode
3) Blank Out Password field in etc cat ie > /etc/passwd
root::0:0:root:/root:/bin/bash

For More Info Try


O Reilly
 

Sunner

Elite Member
Oct 9, 1999
11,641
0
76
If you're using shadow passwords, which is very likely unless you're running some ancient distro, you should edit /etc/shadow rather than /etc/passwd
This file is comma delimited, blank the second field of the root entry.
 

drag

Elite Member
Jul 4, 2002
8,708
0
0
One thing about passwords is that you can disable accounts easily. Go into your /etc/passwd file. In the second slot for active accounts you can see a *.

That means when authenticating you go and look in the shadow file for the passwords. If you eliminate that * you can make it impossible to login using that account. Root can still "su username" and use the account, but it will be impossible for anyone to login as that person.

So if you want you can disable the root account by doing that. Single user mode is about the only way that I can think of to recover from something like that.

edit: Oops Sunner beat me to it.