Enable root account, and disable sudo for the user

If you have installed Debian without a root password, you will automatically have sudo enabled for the user account that you have created during the installation.

When you enable the root account, always disable sudo. You should never have both enabled, as it doubles the surface for malicious software or actors to compromise the system.

  • To enable (unlock) the root account, just give it a password. Open a terminal and type:
    sudo passwd root

    into it, and press Enter.

  • Now you will be prompted for your user password (unless you have used sudo in the same terminal within the last 15 minutes). Type your password and press Enter.
  • Now you will be asked to enter a new password with the following prompt:
    Enter new UNIX passwrod:

    Enter the new root password, and press Enter. The cursor will not move. This is intentional so that the length of the new password is harder to guess by anyone with a malicious intent.

  • Next, you will have to retype the password:
    Retype new UNIX passwrod:

    Confirm your password and press Enter

  • Now you should have enabled the root account. To test it, type the following command:

    and press Enter.

  • Type the new root password and press Enter. If there is no error, and the prompt changes to root@yourhostname#, it all worked fine.
  • Now you should disable sudo, so you have only one way to access root. To do this, it is possible to just remove the user from the sudo group. This might be fine if you are the only user on the computer, but if it's a multi-user system, you might want to completely remove sudo instead. To avoid confusion and any later problems, we'll opt for the second option. While still at the root prompt, type:

    apt purge sudo

    and press Enter. This should remove sudo completely from your system.

    The apt command will be discussed in greater detail in [Discover Debian / installing Applications](/configuring/install-applications/install-new-applications/install from the cli)

  • When finished, type

    and press Enter.

And you are done. You can close the terminal now.

Although there is no standalone script provided for these simple tasks, the Way of Linux Admin console app, available from the Downloads page, hs pre-configured menu options that can make these tasks a lot easier.