LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-07-2008, 06:20 AM   #1
Novatian
Senior Member
 
Registered: Feb 2008
Location: Australia
Distribution: Mint 20.3 MATE, Android, Windows 10, MX Linux and Mint 21.1 MATE
Posts: 1,042

Rep: Reputation: 37
Regaing Lost Root Password?


Hi, I have installed Ubuntu 8.04 but lost my root password, how can I find it again?

Either that or I will have to reconfigure.
 
Old 09-07-2008, 06:27 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Boot from the installation disc (or use any other live-cd Linux distribution), then mount your on-harddisk Ubuntu's root partition, edit there /etc/shadow and empty root user's password field (first field is username, then comes field separator which is :, then comes password field, then field separator :, ...) Save the file and reboot as you usually would - if you did it right, you should now be able to login as root without a password (because it was set blank).

Mounting a partition (assume first primary harddisk partition to be sda1 and mountpoint /mnt):
Code:
sudo mount /dev/sda1 /mnt
Then edit the file:
Code:
sudo gedit /mnt/etc/shadow
In the shadow file are stored user/password information, one row per one user. Here's an example of the root user's line (usually first):
Code:
root:!:13970:0:99999:7:::
First field says "root", second "!" and so on. Second field is the (encrypted) password which you'll want to empty so it becomes like this:
Code:
root::13970:0:99999:7:::
Note that here the password field contained only "!" which is not acceptable char in the password; this means that the account is "locked" and you can't log in as root (default Ubuntu way -- you're supposed to use sudo instead). If you have set up a root password, instead of the exclamation mark the field contains a longish gibberish string which is the encrypted password.

With root account open you can then use passwd to reset other accounts' passwords if you need.

Last edited by b0uncer; 09-07-2008 at 06:30 AM.
 
Old 09-07-2008, 06:50 AM   #3
r3sistance
Senior Member
 
Registered: Mar 2004
Location: UK
Distribution: CentOS 6/7
Posts: 1,375

Rep: Reputation: 217Reputation: 217Reputation: 217
Alternatively you could use single user mode. I believe a quick google seach on "ubuntu single user mode" should give plenty of hits on that. Once in single user mode you can just type "passwd root" and should then be able to reset root's password. Also you may want to check you don't have sudo access with your normal none root account by typing "sudo su -" and retyping your password (not your root password). If that gets you into root then you can just type passwd that way. Single user mode is usually the easiest way to reset a lost root password if their is no sudo access either.
 
Old 09-07-2008, 11:55 AM   #4
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Quote:
Originally Posted by r3sistance View Post
Alternatively you could use single user mode.
You could, but apparently the latest (8.04) version of Ubuntu has thought about that, and by default will ask a password anyway -- you won't get a free entry to the root account that way anymore

It would be good to go to BIOS settings and (in addition to setting up a password for entering the setup utility) set default boot device to be harddisk, disable boot menu so people couldn't switch to CD and set up a password for altering bootloader configuration/entering single-user mode, but as long as the disk is not encrypted, this is all pretty meaningless -- typically harddisks are fairly easy to remove from the machine and plug onto another machine, on which the disk contents are easy to access (bypassing all bootloader and login troubles).

Last edited by b0uncer; 09-07-2008 at 11:59 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
I have lost my root password. admiralpaul Linux - Security 5 07-13-2007 01:10 AM
Lost Root Password Mr.Smith Mandriva 2 11-27-2006 11:20 PM
Lost root password Elong Debian 4 11-18-2006 05:35 AM
root password lost odexut7 Fedora 2 01-18-2006 02:18 PM
Lost root password amirdhagopal SUSE / openSUSE 13 02-10-2005 12:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:19 AM.

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