Lets say we need to add a new user and grand him root privileges.
Use the following commands to create the new user john, grand him the same privileges as root and set him a password :
# useradd -ou 0 -g 0 john
# passwd john
We’ve just created the user john, with UID 0 and GID 0, so he is in the same group and has the same permissions as root.
Grant ROOT Privileges to an Existing USER
Perhaps you already have some user john and you would like to give root permissions to a normal user.
# grep john /etc/passwd
john:x:1001:1001::/home/john:/bin/sh
Edit /etc/passwd file and grant root permissions to the user john by changing User and Group IDs to UID 0 and GID 0 :
# $ grep john /etc/passwd
john:x:0:0::/home/john:/bin/sh
Delete a USER Account with UID 0
You won’t be able to delete second root user with another UID 0 using userdelcommand.
# userdel john
userdel: user john is currently used by process 1
To delete user john with UID 0, open /etc/passwd file and change john’s UID.
For example, change the line :
john:x:0:0::/home/john:/bin/sh
to something like :
john:x:1111:0::/home/john:/bin/sh
Now, you’ll be able to delete user john with userdel command :
# userdel john