LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-21-2012, 08:06 AM   #1
heli37
LQ Newbie
 
Registered: Feb 2011
Posts: 4

Rep: Reputation: 0
super user password


Hi

Havent used my machine in ages and have forgotten the super user password. How can I find or alter it please?

Thanks
 
Old 08-21-2012, 08:14 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Boot up from a Linux Live CD, mount the internal hard drive and edit the root entry in the /etc/password file to remove the first "x". The revised entry will look something like this:
root::0:0:root:/root:/bin/bash

You will now be able to boot into single-user mode and login as root with no password----then you can create new passwords as needed.
 
Old 08-21-2012, 08:18 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939Reputation: 3939
Quote:
Originally Posted by pixellany View Post
Boot up from a Linux Live CD, mount the internal hard drive and edit the root entry in the /etc/password file to remove the first "x". The revised entry will look something like this:
root::0:0:root:/root:/bin/bash

You will now be able to boot into single-user mode and login as root with no password----then you can create new passwords as needed.
You might find that the live-CD can actually do it just with the passwd command, executed when you have booted the DVD and are therefore logged-on as root. It depends somewhat upon exactly which DVD you are using.
 
Old 08-21-2012, 01:20 PM   #4
nittmann
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Rep: Reputation: 0
Cool

deleted

Last edited by nittmann; 08-23-2012 at 12:14 AM.
 
Old 08-21-2012, 02:34 PM   #5
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by nittmann View Post
please disregard the previous two [MODERATED] answsers.... here is how it goes
there is a bit more to it, a couple of steps
Hmm, it seems like your answer is just a really really detailed version of pixellany's. It would be useful to say what you think is wrong with the other answers.

And please don't use orange or other light colours like yellow, they're really hard to read.

Last edited by ntubski; 08-21-2012 at 07:41 PM. Reason: remove quotes of things that moderator removed
 
Old 08-21-2012, 02:42 PM   #6
KernelJay
LQ Newbie
 
Registered: Aug 2012
Posts: 15

Rep: Reputation: Disabled
If you don't have a password set on the bootloader, you may be able to boot into single user mode and run 'passwd' that way without the need for a live cd. Some systems will ask for the root password to boot into single user mode in which case you would need to access the file system through a live CD (or by mounting the hard drive using another system). The last time I checked, Red Hat based systems (i.e. including CentOS and Fedora) did not have this requirement. Booting into single user mode on these systems is just a matter of editing the boot line in grub and adding 'single' to the boot argument list. Here is a link to Red Hat with some details: https://access.redhat.com/knowledge/...booting-single
 
Old 08-21-2012, 03:12 PM   #7
nittmann
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Rep: Reputation: 0
Wink ntubitski: [MODERATED]

deleted

Last edited by nittmann; 08-23-2012 at 12:15 AM.
 
Old 08-21-2012, 03:59 PM   #8
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
Quote:
Originally Posted by nittmann View Post
taking away the 'x' from /etc/passwd prevents pam/shadow from working and the result is always a wrong password
Confirmed, furthermore calling passwd at that point puts the new password in /etc/passwd instead of /etc/shadow:
Code:
~$ su -
Password: 
root@localhost:~# vi /etc/passwd
root@localhost:~# grep root /etc/passwd
root::0:0:root:/root:/bin/bash
root@localhost:~# logout
~$ su -
Password: 
su: Authentication failure
~$ sudo su -
root@localhost:~# passwd
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
root@localhost:~# grep root /etc/passwd
root:$6$tR9JDqAL$7c8DqmIgDPY4io6R4Ypbk/PuVGdaRD6t5dCSHgICmlAIAdOO.avOfdkhfYY9w3Axbu/6Vs7Pa3mkFei6gTTbU/:0:0:root:/root:/bin/bash




When we correct wrong information EVERYBODY wins, it's not a competition.

Last edited by ntubski; 08-21-2012 at 07:44 PM. Reason: remove quotes of things that moderator removed
 
1 members found this post helpful.
Old 08-21-2012, 04:42 PM   #9
nittmann
LQ Newbie
 
Registered: Aug 2012
Posts: 9

Rep: Reputation: 0
Talking nubski: here is why I posted it this way

deleted

Last edited by nittmann; 08-23-2012 at 12:15 AM.
 
Old 08-21-2012, 06:33 PM   #10
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
@nittmann: you may expect us to be lenient towards new LQ members allowing them time to acclimatize but personal attacks and provocations are a direct violation of the LQ Rules you agreed to adhere to when you signed up. Please do not do that again.
 
Old 08-23-2012, 02:52 AM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by ntubski View Post
Confirmed, furthermore calling passwd at that point puts the new password in /etc/passwd instead of /etc/shadow:

When we correct wrong information EVERYBODY wins, it's not a competition.
I just ran a test....

I created a new user normally. Then I used my method (remove the x) and--as expected--I could log in to the new user account with no password. I then assigned a new password, and the account was back to normal ("x" in /etc/passwd, etc.)

I've used this method for recovering from lost passwords many times.........

The implication is that some distros are set up differently????
 
Old 08-23-2012, 09:45 AM   #12
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: CentOS 7.4 with KDE
Posts: 262

Rep: Reputation: 22
Some RedHats boot right into root in single mode, and some don't.

There is yet much better way to get root which works on all distros, but I'm sure unSpawn wouldn't want me saying it.
 
Old 08-23-2012, 09:51 AM   #13
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Add 'single' to the kernel boot parameter. itll boot into single user mode. then 'passwd root'

Edit:

Wasn't sure which distro we were talking about.

This will work on RedHat, Centos, Scientific Linux and Fedora.

Hope that helps.

Last edited by szboardstretcher; 08-23-2012 at 10:26 AM.
 
Old 08-23-2012, 10:24 AM   #14
Quantumstate
Member
 
Registered: Jun 2005
Location: Seattle, Ecotopia
Distribution: CentOS 7.4 with KDE
Posts: 262

Rep: Reputation: 22
Well szboardstretcher, this only works on a few distros as I said, not ones which recognize this security hole.
 
Old 08-23-2012, 11:26 AM   #15
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
//OT comments moved here so this thread can remain on topic from here on.
 
  


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
Geting a new password of super-user thornbush Linux - Newbie 6 02-17-2008 08:36 PM
super user password uchuanng Linux - Server 11 11-17-2007 09:57 PM
How do i set my super user password? Nexxt Ubuntu 4 01-03-2007 11:36 AM
error (super user) password hero_19873 Linux - Newbie 4 05-02-2006 05:50 AM
Super user password in Knoppix 3.9 sfzab Linux - Software 2 12-26-2005 10:08 PM

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

All times are GMT -5. The time now is 06:23 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