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?
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.
There are even more secure ways to erase the hard drive but overwriting with zeroes is the minimum that you should do.
ssd
use the manufacturer's low level command. If the buyer has any computer sense, s/he would wipe it anyway once received.
To lock / erase the root pw
sudo passwd -l root
/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.
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.
-d
and -l
, else on some systems running su
grants access without a password! See also: help.ubuntu.com/community/RootSudo
root
usually doesn't have a password. Yourroot
has? Or do you mean the password you enter when you dosudo something
? That's your password then, notroot
'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.