how to create user that have same permission as root in CentOS 7?


You cannot create another user with the same permissions as root. Root is a system user with special privileges. The privileges of root come from the user ID 0, not from a flag on the account or from the name “root” (that's just a convention, but a universally followed convention, so if you use a different name you'll break a lot of software and sysadmins).

You can have as many users with administrative privileges as you want. They won't be called root or have user ID 0, they're just normal accounts with the privilege to execute commands as root. The most common way to give an account administrative privileges is to configure sudo to allow them to run commands as root. Such accounts are called “sudoers”. Then, to run a command that requires administrative privileges, you run sudo commandname argument….

| improve this answer | |
  • I would say that you are proposing to give a regular user a possibility to escalate privileges, not to have same permissions as root. But I think that OP has to be more specific what exactly he wants to achieve. – Kalavan Oct 26 '16 at 8:15
  • @Kalavan I proposed to give a regular user a possibility to escalate privileges because that's the way it's done. Interpreting the request literally (as in, having processes running as a user that is not root but that have all the privileges of the root user) is impossible because some privileges are tied to the uid value. The actual purpose of having root privileges is to be able to perform actions with root privileges, and sudo is the most common way to do that. – Gilles 'SO- stop being evil' Oct 26 '16 at 9:37
  • And with this comment I would say it is full answer. Thanks. – Kalavan Oct 26 '16 at 10:19
useradd -u 0 --non-unique yourrootuser

You also might want to add it to root group and specify any other switches to create a user you want. User id equal to 0 is most important to achieve your goal.

| improve this answer | |
  • This doesn't create a user with the same permission as root, it creates another name and password for the same user. This is an important distinction. – Gilles 'SO- stop being evil' Oct 25 '16 at 22:14
  • Gilles, yes, this creates another user with the same User ID. And all is special about root is it's id :) – Kalavan Oct 25 '16 at 22:16

issue usermod -aG wheel <username>

This will add your user into group wheel which have same permissions as root.

| improve this answer | |
  • 2
    This is wrong. root has superuser permissions. A non-root user being in the wheel group does not have superuser permissions. – countermode Oct 25 '16 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.