LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 12-03-2006, 02:55 AM   #1
superpingu
LQ Newbie
 
Registered: Oct 2006
Posts: 7

Rep: Reputation: 0
Question Change root password?


How do you change the root password of a Linux box without having the original root password? (You have physical access to the computer.)

please answer this question quickly!!!
 
Old 12-03-2006, 03:15 AM   #2
musicman_ace
Senior Member
 
Registered: May 2001
Location: Indiana
Distribution: Gentoo, Debian, RHEL, Slack
Posts: 1,555

Rep: Reputation: 46
use a live CD like Knoppix, Gentoo Live, any bootable linux cd.
 
Old 12-03-2006, 03:32 AM   #3
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
On a properly secured system that shouldn't be (easily) possible

There are some ways, anyway, if you have not set a bootloader password and can thus boot into single-user mode (get a root account without password).

1) Boot your machine; at the bootloader type
Code:
linux single
or add number 2 at the end of the kernel line; I recall either of those should boot into the single-user mode. When it does, you will be log in as root without password asked (this is why you must set a bootloader password, at least)

2) Once in single-user mode and as root, first try simply issuing
Code:
passwd
If you are not asked for your old password, but just the new one, simply fill it in (twice) and after reboot you should be able to log in with that password. In this case omit the next part 3; if you however are asked for your own password, do this:

3) open a text editor (here vi) and start editing your /etc/shadow file (only accessible to root; has encrypted password information inside). Some older systems might not have this file, in that case you would simply edit /etc/passwd instead, just the same way as you edit this file now (/etc/passwd on newer systems has no encrypted passwords as it's world-readable, it has only the letter x where /etc/shadow has the encrypted password):

Every row on that file includes account information for one account; the first line starts with the word root, it has the root account information. We'll edit this line, and only this. As you can see, the file includes several fields (information) separated by a comma :. The second field (that is, between the second and third comma) has some "garbage-looking" letters, that's the encrypted root password. We'll remove it; let's say the line looked like this first (just an example, this is not from a real file):

Code:
root:$2$A3B4abcd$jx123EOabcwA1BcdefgHi1:12345:0:99999:7:::
after you've removed the second field's data, that line should look like this (in my example):

Code:
root::12345:0:99999:7:::
Now that you've removed that (encrypted) password, save the file and exit. Reboot your machine, and when you're asked to log in, give root as your username (log in as root) and when prompted for a password, just press ENTER (no password). You should now be logged in...

4) Then we'll change the password to something only you know:

Code:
passwd
You are asked the new password (twice), fill it in and you're ok again.

5) Just to mention, the topic of this thread ("Urgent!!!!!!!") is bad; it doesn't tell what the problem is, and thus may not be read too quickly. In the future use more descriptive topics (like "Root password lost"), and even before that, try to search for an existing answer. I'm quite sure somebody has explained this method here already, but since you're a newcomer (only 4 posts so far), I don't mind. Hopefully you'll get the password back.

6) To make sure nobody else does this for your root account ( heh ), make sure nobody else has physical access to your machine, root logins are forbidden over the network, only you know the root password and that your bootloader has a password only you know (that way if somebody got to your machine, it would take more time to break it). At least.

EDIT: forgot to mention, just because of these live-cds and stuff, you should also set BIOS password to prevent changing (among others) your boot settings, and set it boot from harddisk first/only. This would prevent or slow down somebody booting from a live-cd and stealing everything unencrypted (and even that) on your harddisk.

Last edited by b0uncer; 12-03-2006 at 03:35 AM.
 
Old 12-16-2006, 08:20 PM   #4
broch
Member
 
Registered: Feb 2005
Distribution: Slackware-current 64bit
Posts: 465

Rep: Reputation: 32
Quote:
or add number 2 at the end of the kernel line;
single user is "1'
runlevel 2 is multi-user, definable runlevel will start most services without network and X this is not used,


Quote:
root:$2$A3B4abcd$jx123EOabcwA1BcdefgHi1:12345:0:99999:7:::
actually leave
root::::
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cannot change (root)password jurp5 Linux From Scratch 4 04-03-2018 04:32 PM
How could normal user obtain root password or change root password ckamheng Debian 18 02-18-2009 10:28 PM
change root password padmakar Linux - Newbie 2 11-21-2006 12:44 AM
change Root Password even if the password in the grub is also set sheelnidhi Linux - General 6 08-30-2006 07:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 10:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration