50

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.

3
  • 4
    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. Mar 25, 2011 at 19:55
  • @Gilles: that’s fantastic, I had no idea. Mar 25, 2011 at 20:01
  • Have you considered, instead, sudo. Sep 6, 2018 at 17:48

3 Answers 3

82

Ah, use the passwd program as root:

sudo passwd root

Or, if you’re running as root already (which you shouldn’t be), just:

passwd

The root argument can be omitted, because when you execute passwd it defaults to the current user (which is root, as only root can change the root password).

12
  • 1
    Obvious in hindsight, really. :) Mar 25, 2011 at 14:15
  • @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. Mar 25, 2011 at 14:18
  • 1
    Should be sudo passwd, or just plain passwd if you are running with root privileges.
    – phunehehe
    Mar 25, 2011 at 14:33
  • 1
    @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.
    – phunehehe
    Mar 25, 2011 at 16:11
  • 1
    @Katerberg You can just use su -c "passwd" Nov 16, 2016 at 15:27
5

If you're going to be doing a lot of command-line administration, you might find it useful to check out the man pages for usermod(8), chfn(1), chsh(1), passwd(1), crypt(3), gpasswd(8), groupadd(8),

-2

You have to boot in Recovery Mode before using Paul D. Waite's suggestion:

  1. Right after booting your Debian system choose "boot in Recovery Mode"
  2. Right after booting into "Recovery Mode" right at the command prompt simply type:

    sudo password root
    

    then the system will ask for the new Root's password once and twice to verify and you ARE done.

1
  • 1
    “You have to boot in Recovery Mode before using Paul D. Waite's suggestion” — Really? I don’t remember doing that. Is this a new thing in a new version of Debian? Sep 17, 2014 at 15:56

You must log in to answer this question.

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