HOWTO - reset a lost Ubuntu password
I loaded one of my test Ubuntu virtual machines today (one that I hadn't used for a month) and, surprise, I had forgotten the password. This sort of thing happens from time to time, and if you're new to Linux, it can be a little disconcerting.
Losing your root password isn't the end of the world, though. You'll just need to reboot into single user mode to reset it. Here's how to do it on a typical Ubuntu machine with the GRUB bootloader:
Boot Linux into single-user mode
- Reboot the machine.
- Press the ESC key while GRUB is loading to enter the menu.
- If there is a 'recovery mode' option, select it and press 'b' to boot into single user mode.
- Otherwise, the default boot configuration should be selected. Press 'e' to edit it.
- Highlight the line that begins with 'kernel'. Press 'e' again to edit this line.
- At the end of the line, add an additional parameter: 'single'. Hit return to make the change and press 'b' to boot.
Change the admin password
The system should load into single user mode and you'll be left at the command line automatically logged in as root. Type 'passwd' to change the root password or 'passwd someuser' to change the password for your "someuser" admin account.
Reboot
Once your done, give the three finger salute, or enter 'reboot' to restart into your machine's normal configuration.
That's all there is to it. Now just make sure to write your password down on a post-it and shove it somewhere safe like under your keyboard. :)
Posted by Jason Striegel |
Sep 3, 2008 10:37 PM
Linux, Ubuntu |
Permalink
| Comments (16)
Recent Entries
- Controlling a Nikon or Canon camera with a Nintendo DS
- Zoom H2 microphone modification
- Sweetcron - open source lifestream
- Google Gadget that monitors Arduino sensor data
- PhoneGap - develop native iPhone applications in HTML/Javascript
- Plotting streaming data in real-time with Gnuplot
- Arduway: LEGO and Arduino make a Segway
- WiFi robot
- Resin casting
- The (unfortunate) iPhone Development Story
Comments
Newest comments listed first.
| Posted by: bachterman on September 4, 2008 at 12:00 AM |
so this means i can change anyone's password on ubuntu?
i'm having concerns about security since the new google chrome bubble popped. :/
| Posted by: paco on September 4, 2008 at 12:02 AM |
... then its easy enough to "sudo passwd" to reset it. Or just live life in sudo, and "sudo su" when ever you need a terminal.
| Posted by: kvn on September 4, 2008 at 11:17 AM |
@bachterman
It's long been known that all bets are off if you have physical access. You could set a password on grub, but that doesn't stop someone from booting a CD or removing the harddrive and mounting it. Next.
@paco
Yeah but ubuntu doesn't typically have a root password.
| Posted by: Seth on September 4, 2008 at 12:07 PM |
You can use a capital "S" instead of "single" if you're feeling lazy
| Posted by: Jason Striegel on September 4, 2008 at 1:25 PM |
@Ronny - Re:Loosing
Oh, come on. To cast loose. To free from your control. To eject from your memory like a hot rocket of forgetfulness. Loosing your password.
(I've corrected the post. Appropriate dose of shame has been applied.)
| Posted by: Steve on September 5, 2008 at 8:12 AM |
single user mode may still occasionally prompt you for a password.
add init=/bin/bash to your kernel line to go straight to a bash prompt from bootup. You'll probably have to remount your / partition as rw, and remember to sync after making any changes. You won't be able to shut down nicely from this state, so ctrl + alt + del is the only option.
| Posted by: Matthew Musgrove on September 5, 2008 at 8:52 AM |
Actually this isn't Ubuntu or Debian specific. It is a feature of the Linux kernel and has worked that way since at least 1995 but probably even a few years prior to that. Different bootloaders will have different methods to editing the kernel line though.
| Posted by: CB on September 5, 2008 at 2:39 PM |
If you give root a password, you'll have to enter that password to boot into single user mode. Correct me if I'm wrong.....
| Posted by: michelle on September 5, 2008 at 3:17 PM |
I saw this on the google reader this morning and didn't think much about it. JUST called the boyfriend who is moving into a new house and got an ear full about him forgetting his password...blah blah blah.
I saved the day thanks to this little tip. More points for the slightly tech savvy girlfriend. Thanks!
| Posted by: Rishav uprety on September 6, 2008 at 7:43 AM |
this doesn't work if the grub is password protected.
Regards
techspalace.blogspot.com
| Posted by: mjc on September 6, 2008 at 8:51 AM |
"If you've only forgotten the root password..
... then its easy enough to "sudo passwd" to reset it. Or just live life in sudo, and "sudo su" when ever you need a terminal."
I'm pretty sure you need to enter the old password to reset it, so that doesn't help if you've forgotten it.
| Posted by: Robert on September 6, 2008 at 10:50 PM |
You only have to enter the old password for non-root users, if you're root you can, of course, just edit the /etc/passwd and /etc/shadow files directly. So passwd doesn't ask for the old password.
| Posted by: Mikko on September 7, 2008 at 8:40 AM |
No box is secure if one can get a physical access to it. You should use a password to secure the bios (no booting from CD) and use a password to secure the GRUB.
If you are allowed to boot from CD you can always change the root password.
Greetings,
mikko lightlinux.blogspot.com
| Posted by: Isabelle on September 28, 2008 at 11:59 AM |
Hallo!
I have a four year old computer (Packard Bell) with Linux Debian and Gnome password manager. No one know the username and password. I do not want to uninstall Debian and Gnome because it´s folders with pictures on the computer. Before I uninstall everything I want to save the pictures if it´s possible. Is it possible. I am a really beginner with linux.
Best regards
Isabelle
| Posted by: Isabelle on September 28, 2008 at 12:01 PM |
Hallo!
I have a four year old computer (Packard Bell) with Linux Debian and Gnome password manager. No one know the username and password. I do not want to uninstall Debian and Gnome because it´s folders with pictures on the computer. Before I uninstall everything I want to save the pictures if it´s possible. Is it possible. I am a really beginner with linux.
Best regards
Isabelle
Leave a comment
Bloggers
Welcome to the Hacks Blog!
Categories
- Ajax
- Amazon
- AppleTV
- Astronomy
- Baseball
- BlackBerry
- Blogging
- Body
- Cars
- Cryptography
- Data
- Design
- Education
- Electronics
- Energy
- Events
- Excel
- Excerpts
- Firefox
- Flash
- Flickr
- Flying Things
- Food
- Gaming
- Gmail
- Google Earth
- Google Maps
- Government
- Greasemonkey
- Hacks Series
- Hackszine Podcast
- Halo
- Hardware
- Home
- Home Theater
- iPhone
- iPod
- IRC
- iTunes
- Java
- Kindle
- Knoppix
- Language
- LEGO
- Life
- Lifehacker
- Linux
- Linux Desktop
- Linux Multimedia
- Linux Server
- Mac
- Mapping
- Math
- Microsoft Office
- Mind
- Mind Performance
- Mobile Phones
- Music
- MySpace
- MySQL
- NetFlix
- Network Security
- olpc
- OpenOffice
- Outdoor
- Parenting
- PCs
- PDAs
- Perl
- Philosophy
- Photography
- PHP
- Pleo
- Podcast
- Podcasting
- Productivity
- PSP
- Retro Computing
- Retro Gaming
- Science
- Screencasts
- Security
- Shopping
- Skype
- Smart Home
- Software Engineering
- Sports
- SQL
- Statistics
- Survival
- TiVo
- Transportation
- Travel
- Ubuntu
- Video
- Virtualization
- Visual Studio
- VoIP
- Web
- Web Site Measurement
- Windows
- Windows Server
- Wireless
- Word
- World
- Xbox
- Yahoo!
- YouTube
Archives
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
Recent Posts
- Controlling a Nikon or Canon camera with a Nintendo DS
- Zoom H2 microphone modification
- Sweetcron - open source lifestream
- Google Gadget that monitors Arduino sensor data
- PhoneGap - develop native iPhone applications in HTML/Javascript
- Plotting streaming data in real-time with Gnuplot
- Arduway: LEGO and Arduino make a Segway
- WiFi robot
- Resin casting
- The (unfortunate) iPhone Development Story
www.flickr.com
|





