ROOT , The super user in LINUX , Lets learn how to create user with root privileges in Linux, delete a root user or make user root
How To Create USER Account with ROOT Privileges
Commands to create the new user abhinav, grant the root privileges & set password :
# useradd -ou 0 -g 0 abhinav
passwd kakku
We created the user abhinav, with UID 0 and GID 0, so he is in the same group and has the same permissions as root.
Giving ROOT privillages to existing user
Example user abhinav exists and we wanna give it ROOT privillages
# grep abhinav /etc/passwd
abhinav:x:1001:1001::/home/abhinav:/bin/sh
Edit /etc/passwd file and grant root permissions to the user abhinav by changing User and Group IDs toUID 0 and GID 0 :
# $ grep john /etc/passwd
abhinav:x:0:0::/home/john:/bin/sh
Delete a USER Account with UID 0
We can’t delete second root user with another UID 0 using userdel command.
# userdel abhinav
userdel: user john is currently used by process 1
To remove user abhinav with UID 0, open /etc/passwd file and change abhinav’s UID.
For example, change the line :
1 |
<span class="pun">abhinav:</span><span class="pln">x</span><span class="pun">:</span><span class="lit">0</span><span class="pun">:</span><span class="lit">0</span><span class="pun">::</span><span class="str">/home/abhinav</span><span class="pun">:</span><span class="str">/bin/</span><span class="pln">sh</span> |
to something like :
1 |
<span class="pun">abhinav:</span><span class="pln">x</span><span class="pun">:</span><span class="lit">111</span><span class="pun">:</span><span class="lit">0</span><span class="pun">::</span><span class="str">/home/abhinav</span><span class="pun">:</span><span class="str">/bin/</span><span class="pln">sh</span> |
Now, we can remove user abhinav with userdel command :
# userdel john