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?

Babu
  • 71

3 Answers3

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.

Bichoy
  • 3,106
  • 2
  • 21
  • 34
  • 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. – dafnahaktana Sep 17 '22 at 07: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/

Vynylyn
  • 85
  • 1
    @Vynlyn You can also refer to this question: http://unix.stackexchange.com/questions/8581/which-is-the-safest-way-to-get-root-privileges-sudo-su-or-login – Bichoy May 27 '15 at 07: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. – Gilles 'SO- stop being evil' May 27 '15 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 May 16 '20 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).

Dano
  • 34
  • 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 May 27 '15 at 06:51
  • Well I didn't know that :) – Dano May 27 '15 at 07:10
  • 1
    no worries, we all learn here. – Bichoy May 27 '15 at 07:28