New User With Root Access and Without Sudo

9,849
  1. It is recommended not to use another user as root and just use sudo permissions.
  2. You can simply add user by sudo adduser <username>.
  3. You can change the uid and gid to root uid and gid by using sudo nano /etc/passwd
    • you will see users at the same syntax as this example:
    • root:!:0:0::/:/usr/bin/bash
    • newroot:x:1001:1002:,,,:/home/newroot:/bin/bash
    • change your new user uid and gid to the same as root newroot:x:0:0:,,,:/home/newroot:/bin/bash
  4. Look for the user you created and change the uid and gid to the same as root gid and uid.
  5. To look what the uid and gid of the root you can just look in the same file at the root user or use the command id root.
    • on the most of the distributions the uid and gid of the root is 0.
  6. I AM SAYING AGAIN IT IS NOT RECOMMENDED TO PUT ANOTHER USER AS ROOT
    • you can get the same permissions by using sudo command.
  7. To give you new user the sudo permissions wich is recommended then the first part on my answer you can simply make it by:
    • sudo useradd <NEWUSER>
    • sudo usermod -a -G sudo <NEWUSERNAME>
    • the -a for not overwriting and deleting the "old" groups of the user.
Share:
9,849

Related videos on Youtube

Ven Ven
Author by

Ven Ven

Updated on September 18, 2022

Comments

  • Ven Ven
    Ven Ven over 1 year

    I Know about the security risk and I know about sudo, sudo su, sudo -i and the sudoers file but what I need is to create a new user (not root user) with the root privilage without having to use sudo at all. how to do that ? and don't give me an altrnative ways please thank you

    • Soren A
      Soren A over 3 years
      If you know about the security risks, then why do it. There are (almost) never a reason to be permanently logged in with root-rights.
    • Ven Ven
      Ven Ven over 3 years
      if you use virtualbox you will understand :)
    • Soren A
      Soren A over 3 years
      I have used VirtualBox .. I still don't understand. Please explain.
  • Ven Ven
    Ven Ven over 3 years
    The system does not recoginize the new user and it think that it is the root user .. is there a way around that ?
  • Ven Ven
    Ven Ven over 3 years
    what about groups for example ? can I add the new user to the root group
  • Ven Ven
    Ven Ven over 3 years
    not helpful about what I asked you :(
  • johncli
    johncli over 3 years
    try to change the gid and uid on the /etc/passwd without changing the path that will work out, (i just did on my ubuntu)
  • Admin
    Admin almost 2 years
    what if I'm running a service as root and wanted to drop permissions ?