7

I installed Debian OS today and while installation I skipped the option to create root user and chose to use sudo. Now I would like to create root user account. Is there any way to create the root account now?

3 Answers 3

19

The root account is always there, you just need to set a password for it:

sudo passwd root

And enter a password when prompted to.

1
  • the root account is actually not always there. I created a debian fs with debootstrap. When running passwd root I get passwd: Cannot determine your user name. Commented Sep 17, 2022 at 7:37
7

As most Linux experts believe so, creating a root account ain't a good idea and that's why people mostly stick to SUDO (Although, sometimes it might make you kind of nervous.) But if you can accept risks, this piece of code would activate a root account:

sudo passwd root

I'd suggest you deactivate it after you satisfy your need with it. You may want to take a look at this article for better understanding the case and the process:

http://sathyasays.com/2008/05/27/enabling-and-disabling-root-account-in-debianubuntu/

3
  • 1
    @Vynlyn You can also refer to this question: unix.stackexchange.com/questions/8581/…
    – Bichoy
    Commented May 27, 2015 at 7:03
  • Actually, enabling the root account (not creating: it always exists) is not intrinsically a security risk. It's a problem on multiuser systems (or more precisely multi-administrator systems) because if several people know the root password, you can't know who used it in a given instance. But having a root account that you can log into with the password is not less secure than having an account that can gain root with sudo. If it makes you nervous, you're uninformed or not thinking with security in mind. Commented May 27, 2015 at 22:24
  • @Gilles'SO-stopbeingevil' so does it makes sense to make root account in case of single-user system, when it sucks me to use sudo for every "common" command? Otherwise, what advantage I have using sudo without having root account?
    – Herdsman
    Commented May 16, 2020 at 20:33
-3

The UID and the GID of root are 0. So you have to run those commands:

groupadd --gid 0 root
useradd --home /root --uid 0 --gid 0 root

You can name this account likeyou want, what's important here is the UID (user id).

3
  • 5
    Why would he create it? Shouldn't it be there by default? I know (at least in the old days), skipping the root account just doesn't set a password to it so nobody can login with it, but it is always there....
    – Bichoy
    Commented May 27, 2015 at 6:51
  • Well I didn't know that :)
    – Dano
    Commented May 27, 2015 at 7:10
  • 1
    no worries, we all learn here.
    – Bichoy
    Commented May 27, 2015 at 7:28

You must log in to answer this question.

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