How do you change the root password on Debian?
I want to change the password I assigned to root on my Debian webserver to something longer and more secure.
How do I do that? I haven’t forgotten/lost the current password, I just want to change it.
To find this out for yourself, run `apropos password`: you'll get a list of commands that contain “password” in their short description. You can narrow the search a little with `apropos -s 1 password`: `-s 1` restricts to section 1 of the manual, which contains user commands.
sudo passwd root
Or, if you’re running as root already (which you shouldn’t be), just:
rootargument can be omitted, because when you execute
passwdit defaults to the current user (which is root, as only root can change the root password).
@Shadur: *painfully* :) I’d just never done it before, and the Google links I found first were for folks who had forgotten the root password.
Should be `sudo passwd`, or just plain `passwd` if you are running with root privileges.
@phunehehe: ah, gotcha. Answer edited; do I need `root` after `sudo passwd` if I’m not running as root?
@Paul I took liberty in editing your answer. There are a few ways to run things as root, and when `passwd` is run as root, it defaults to modify the `root` user.
Maybe should say su -c 'passwd root' for systems like CentOS, Fedora, RHEL where sudo isn't installed. This would help teach newbies not to run as root by default.
@jamespo: no. When I Googled initially, I only noticed links saying how to reset a lost root password. I do tend to ask on SE sites quite quickly, but only to make the answer easy for me to find in the future.
@PaulD.Waite It's worked, but when i'm going to login via Ctrl+Alt+F1 , it's says incorrect login!