The Mac Observer

Skip navigational links

Mac OS X Tip - No Password, No Root, No CD? No Problem.

by , 11:00 AM EDT, June 16th, 2003

Say you've lost your account password, you don't have a system CD on hand, and you didn't enable root. Say you have no other way to log into that machine. Say you need access to the files on that machine right now.

Say you're in deep you-know-what, bucko.

Fortunately, there's a five minute fix -- all it takes is a little digging into the command line, and you're on your way. We got this hint from a technician who found himself in the deep end while trying to recover data from a PowerBook on extremely short notice.

My problem was this: I had no MacOS X CD, no user password, and root wasn't enabled.

What I had was this: A MacOS X Laptop that automatically logged in as an administrative user, but prompted me to enter a password whenever I attempted to perform an administrative task. A password I didn't have.

I needed to either reset the password on the logged in account, or enable root access and authenticate as that user. The solution:

  1. Reboot the machine into single user mode (CMD+S on boot)
  2. Mount the root file system as read/write (mount -uw /)
  3. Edit the SUDOERS file (visudo)
  4. Change all occurences of "(ALL) ALL" to "NOPASSWD: ALL" (Note: You'll need to know your way around the text editor vi -- check out the vi tutorial in MacOS X Command Line 101 for more. -TMO)
  5. Save the SUDOERS file and reboot (ESC-w, ESC-q, 'reboot')
  6. Open a terminal and execute the command 'sudo passwd root'

Voila! I was able to change the root password without being prompted for any other password. This done, I could authenticate as root and do anything I wanted on the box.

Here's the kicker -- this guy is a Windows technician. Who'd have thunk it?

So there's one method, but we discovered this only works if you have an account that automatically logs itself in when you boot the Mac. We're not all so lucky. What to do? We'll one-up this method with a way that works for any user account.

  1. First, you'll need to reboot into single-user mode. This boots your Mac into a text-only mode (you might be familiar with this experience if you've ever had to run fsck). You'll see instructions on how to run the file system check -- fsck -- and then a command prompt. Enter the command mount -uw / so that we can make changes to the disk.
  2. Next, you need to be able to make changes to the users' accounts on your Mac in order to reset your password, and we'll do that with NetInfo. Start NetInfo by typing Systemstarter. You'll see a pile of messages appearing, which might seem familiar to you if you've ever watched the startup progress bar. When you see the message System started. and a stationary cursor, hit Return. You'll see the shell prompt appear again.
  3. Now that NetInfo is running, we can change our lost password. If you don't know the short username for your account (for example, 'jane' instead of 'Jane Doe'), you'll need that - enter the command niutil -list . /users and hit Return, to see the names of the accounts on your Mac.
  4. Now that you know the name of the account you want to use, enter the command passwd user -- where user is the short name of the account you're changing. You'll be told that you're changing the password for user and asked to enter it twice. Do this, being careful with your typing: you won't see the characters you're typing, or stars. Watch that Caps Lock key, while you're at it.
  5. Now type reboot and press Return once more to reboot your Mac. You should now have no problem logging in.

There you have it -- two really quick ways to get back into your machine when you're in a pinch. Now don't forget it this time!

The Mac Observer Spin:

On to the dark side of this silver-lined cloud. As the Windows tech noted in his blog entry, no system is secure when you have physical access to it. That's an old adage in the computer industry, and it holds just as true today as it did when security was first becoming an issue umpteen years ago. These two workarounds we are publishing can help you get into a system from which you have been locked out, but they can also help a bad guy get into your system.

Mac OS X is a very solid OS with a security record that Microserfs dream about in their fitful and guilt-ridden nights. It's nigh on impossible (at least right now) for someone to gain control of your system remotely, but if they have access to the box itself (or the notebook), and they are determined to do so, they can get your files. Heck, even starting up a Mac in FireWire Target Mode is going to let someone have your system, and if they have a Mac OS X CD, they can just reset the password through the utility included on that CD. So, if you want your system to be secure, mind who has access to it.

Observer Comments

Show: Subjects Only | Full Comments
Close Name:Guest
Subject: Blocked out from opening in single user ibook G4

CMD+S on boot does not work due to open firmware. I'm very limited in utilizing my 12" Ibook G4 1.07 GHz Power PC 256 MB built-in. I don't have the password or admin user name to the admin account. I purchased this computer through Ebay and now I'm unable to contact the seller. I even tried removing the Hard Drive. I did not replace the drive just removed it for a few hours. I read this advice online. I've also read to take out the Vram but I didn't do this step. After taking this apart I wish I would have. Wow what a chore to get to the hard drive. How can I gain control of my new but slightly used computer. Any help would be greatly appreciated. I do have the CD but I'm prompted to give the open firmware admin user name and pw when I try and boot from the CD. Everything I've tried will not give me access to the computer. Help would be greatly appreciated

Close Name:Intruder -   TMO Mac Specialist Posts: 3149 Joined: 07 Jul 2004
Subject:

You can try this:

1) Add or remove DIMMs to change the total amount of RAM in the computer.

2) Then, the PRAM must be reset 3 times. (Command + Option + P + R).


See if that will reset the Open Firmware password. If not, post again, and we'll see what else can be tried.

Close Name:Guest
Subject:

Quote
Intruder wrote:
You can try this:

1) Add or remove DIMMs to change the total amount of RAM in the computer.

2) Then, the PRAM must be reset 3 times. (Command + Option + P + R).


See if that will reset the Open Firmware password. If not, post again, and we'll see what else can be tried.


I am a troll. Ignore me.

Close Name:Guest
Subject: Thanks!

You actually saved me money

Close Name:Bryan -   TMO Staff Posts: 7340 Joined: 11 Jun 2001
Subject: Re: Thanks!

Quote
Anonymous wrote:
You actually saved me money


Too cool, Guest.

Close Name:Guest
Subject: Thanks Intruder

Thanks for the tip man! I was able to boot an ibook g4 that has a locked firmware.

Close Name:Guest
Subject: CMP

I lost my Admin password and i cant do anything

Close Name:Guest
Subject: cant's run niuti to see the namesn help

I'm trying this process and it seems that is working but I cannot run niuti/ -list. /users
Please help

Close Name:Guest
Subject: need admins password but dont have cd

i need the admins password but dont have a cd can you help me

Close Name:LaurieF -   TMO Forum Mod Posts: 3547 Joined: 15 Jun 2001
Subject:

Quote
Guest wrote:
i need the admins password but dont have a cd can you help me


Obviously not, since you can't read.

Close Name:Guest
Subject: The same for OS 9.2?

I have tried the above many times on OS X and its worked great. But now I have an iBook Clamshell with OS 9.2. It seems like CMD+S doesn't work. Any advice on how to do the same but with OS 9.2.

Thanks

Close Name:Guest
Subject: neither of these worked for me

I tried this on an eMac with 10.3.5 on it last night. It auto-logins to a non-privileged parental controlled user. So
the first technique didn't work.

After running Systemstarter, I checked and netinfo still wasn't
started. I tried to manually start it, (cd /var/db/netinfo; netinfod -s local) but that wouldn't start it.

I ran out of time. So I couldn't get in.

I also had boxed set of 10.3 CDs (not the ones that came with
the eMac), and it wouldn't boot. It would start, then I would
get a dark grey circle with a slash (no sign) on the screen and nothing would happen. There was no password on the openboot prom.

I've since got the administrators password, so I can procede,
but I was curious why I couldn't get this to work.

Close Name:Guest
Subject: Never used a mac

Hi, I have a password protected iMac with 2002 on the bottom but I think it is summer ,01. It is Indigo and has either os x9 or 10.4. I never used a mac and someone was giving it away so I figured I'd give it a try. The install cd I have is from an eMac with 10.4.2. Everytime I try to boot from it ,it gets spit out. CMD S gets me to the command line but I'm not familier with it. How can I get in to reset te password or do a clean install. Any help would be great. Thanks, Joseph

Close Name:Intruder -   TMO Mac Specialist Posts: 3149 Joined: 07 Jul 2004
Subject:

It won't boot off an eMac CD. You will have to get a retail install of OS X.

Close Name:yoyo52 Posts: 1174 Joined: 02 Feb 2002
Subject:

This is interesting, and welcome information. On the other hand, I wonder if advice like this helps people who should not be helped. I had my old 400 MHz G4 AGP stolen a while ago (how it happened is not important) and of course it was password protected on boot. I hope that whoever stole it can't use it . . . but here's a slew of advice on how to by-pass the password.

I know--like with all technology there's a potential good and a potential bad to whatever information is provided. I'm not really objecting, just venting a bit.

Close Name:Intruder -   TMO Mac Specialist Posts: 3149 Joined: 07 Jul 2004
Subject:

I hear what you are saying. Unfortunately, the same advice is available from Apple itself, as well as most of the fixit forums.

Close Name:Guest
Subject: Thanks TMO

Guess I have to find a disk

Close Name:Guest
Subject: thanks!

This saved me a lot of trouble. I got this mac from my dad who has type II dimentia and altzheimers and needless to say the password he gave me didn't work. If only I knew I could start it in a shell! after all these years using linux... I did notice that unlike linux you can't just alter the passwd file to create a blank password...

Close Name:Guest
Subject:

how do i use the Systemstarter if it tells me that it didnt complete successfully

Close Name:Guest
Subject: Versions

What versions does this work on?

Close Name:Guest
Subject: um?

After typing 'niutil -list . /users' the system doesn't do anything for a bit and goes back to the prompt without displaying anything else. Furthermore, 'passwd CoolGuy' (or whatever user i use) does the same thing.

Close Name:Guest
Subject: typing passwd whoever hangs then brings back to prompt

What's up with that?

Close Name:Guest
Subject: try this...

all you have to do after you done /sbin/SystemStarter is type "passwd root" to change the root password

Comment on this Article


You cannot edit your comments.   You cannot delete your comments.

Comments are currently closed. Please email the author instead.


Recent Headlines - Updated July 5th

Fri, 10:29 AM
News - Apple Warns of Learning Interchange Security Breach
7:30 AM
News - Happy Fourth of July!
Thu, 6:07 PM
TMO Scoop - Psystar Moves to Drop Bankruptcy Ahead of Apple Legal Battle
5:37 PM
News - Uncomfirmed Reports Say Apple & Nvidia On The Outs
4:57 PM
News - Microsoft Sick Over Barf Ad
4:09 PM
Product News - KRK Ships R6 Passive Studio Monitor for Recording
3:45 PM
John Martellaro's Blog - Particle Debris (week ending 7/2)  Juiced, Joost and Goosed
3:12 PM
Product News - ExactScan 2 Pro Released
1:56 PM
Deal Brothers - Apple TV with 160GB Hard Drive:  $324.00 Delivered
12:46 PM
TMO Appearances - TMO Appearances Jeff Gamet Shares iPhone Apps on MacJury
10:41 AM
Product News - Art Text 2.2 Adds New Templates, Layer Options [Updated]
10:04 AM
Hot Forum Topic - Deciphering Mac Sales

The Mac Observer Reader Specials

  • __________
  • Buy Stuff, Support TMO!
  • Podcast: Mac Geek Gab
  • Podcast: Apple Weekly Report
  • TMO on Twitter!