10

I want to erase the root password I had set on my laptop, so that I can sell it. I currently have Ubuntu 16.04.

I've tried following some instruction videos on YouTube but they didn't work.

How can I erase the root password on my system?

16
  • 11
    On Ubuntu root usually doesn't have a password. Your root has? Or do you mean the password you enter when you do sudo something? That's your password then, not root's. To be honest: I'd wipe the disk before selling the laptop. The buyer can always boot in emergency mode and then see your HDDs content, even if he doesn't know the pwd.
    – PerlDuck
    Jan 4, 2018 at 20:12
  • 24
    Anyway, for selling the laptop I would recommend wiping the whole disk. Your Ubuntu account password is probably the least important secret on that device (unless you use that same password for other things too).
    – Byte Commander
    Jan 4, 2018 at 20:13
  • 6
    I agree with the previous advice to wipe the drive. If the buyer wants Ubuntu, you can make a fresh installation afterwards.
    – sudodus
    Jan 4, 2018 at 20:25
  • 3
    I don't agree with the above 2 users: if the content of the harddisk is important always sell a system without the harddisk. If you do not care about the content ... wipe the disk and be done with it.
    – Rinzwind
    Jan 4, 2018 at 21:11
  • 2
    @Rinzwind Why? Do you think data can be recovered from a wiped drive? Or are you saying the OP should keep the drive so he still has access to the data?
    – marcelm
    Jan 5, 2018 at 22:19

3 Answers 3

61

If you are selling the laptop it is a much better idea to wipe the hard disk completely, so that nobody can see your private information.

  1. Boot from an Ubuntu live CD or USB.
  2. Launch Disk and delete all partitions on the laptop's hard drive.
  3. To go Format and where it says erase, select "Overwrite existing data with zeroes (slow).
  4. Wait up to a few hours.

There are even more secure ways to erase the hard drive but overwriting with zeroes is the minimum that you should do.

4
  • 7
    Couldn't agree with this more. Wipe the drive. If it is an ssd use the manufacturer's low level command. If the buyer has any computer sense, s/he would wipe it anyway once received.
    – Mark
    Jan 5, 2018 at 0:47
  • 2
    While I agree that this is the real answer to the question when it comes to selling a laptop... It doesn't really answer how to change the password. I'm curious what the true method of changing the password is. Sometimes you it's easier to change the password then reinstall everything it took to make Ubuntu work in the first place especially if there were compatibility issues Jan 5, 2018 at 17:48
  • Note that there won't be any OS left on the laptop afterwards - so the buyer will have to install one themselves. Jan 6, 2018 at 7:21
  • Yes, or the seller could then proceed to put a fresh install of Ubuntu on there (as stated in a suggested edit by @Caleb which would have been better as a comment) Jan 7, 2018 at 23:40
10

To lock / erase the root pw

sudo passwd -l root
5
  • 4
    I found this doesn't erase the root password. A quick edit of /etc/shadow puts it back.
    – Joshua
    Jan 5, 2018 at 17:42
  • 1
    @Joshua Well, yes, editing /etc/shadow can restore the password, but someone who can edit /etc/shadow could just as well change the password to anything they want and effectively gain full root access that way. So I think you have to assume that, if your "adversary" has access to edit /etc/shadow, all hope is lost. Given that, this seems reasonably effective for the cases where you want to protect from someone who doesn't have such access.
    – David Z
    Jan 7, 2018 at 8:04
  • @DavidZ: My understanding is he wants to destroy the password to prevent the buyer from learning it.
    – Joshua
    Jan 7, 2018 at 19:41
  • 1
    @Joshua /etc/shadow only stores password hashes though. It's practically impossible to recover the real password from the hash in there.
    – Byte Commander
    Jan 7, 2018 at 19:56
  • The hashing scheme used for any individual password in /etc/shadow could be one of a number of schemes supported by crypt and if it was set more than a couple of years ago (eg you've upgraded through a few LTS releases) it may still be DES or MD5, both easy-to-bruteforce. The newer default is a SHA-2 based scheme using many iterations which mitigates this. Jan 7, 2018 at 22:52
6

As already pointed out in both comments as well as thomasrutter's answer, the below probably isn't what you actually want to do. You're probably better off clearing the hard disk (by overwriting it in its entirety), or removing it and selling the laptop without the hard disk. However, to answer the question that you did ask...


To erase the password for a user account, including root, the correct (and portable; this should work on any Linux system with sudo configured and a GNU userland, which covers most modern desktop and server Linux distributions) way is to start a terminal and then

sudo passwd --delete root

Alternatively, use -d in place of --delete (they are synonymous).

This will set the password for the named account (in this case, root) as empty, effectively erasing it, but will keep the user account and its files intact. Note that this allows logging in with the root account, trivially allowing full access to all files on the system.

Never delete the root account or files owned by it, unless you know for a fact that it's safe to delete such files. The root account is not used by humans on modern versions of Ubuntu (I don't know if ancient ones did use it), but it's required for the system to function properly.

4
  • 6
    Might it be appropriate to move the last paragraph (containing "the above probably isn't what you actually want to do") to the beginning, so that it has the most chance of being heeded?
    – LSpice
    Jan 5, 2018 at 21:29
  • 1
    Thanks a lot. Yes, I think it is not the password I should be worried about :) i’d rather clear the hard disk :)
    – Mafe
    Jan 6, 2018 at 5:38
  • 1
    @LSpice Good idea. Done.
    – user
    Jan 6, 2018 at 13:37
  • As far as I remember you may have to use -d and -l, else on some systems running su grants access without a password! See also: help.ubuntu.com/community/RootSudo
    – Wilf
    Jan 6, 2018 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .