How to add an admin user in Linux

How to add an admin user in Linux

To add a new user with admin (root) privilege, named "new-username" with password "new-username-pass"

sudo adduser new-username
sudo usermod -aG root new-username
sudo passwd new-username

Then type a new username's password or follow the instruction of the interactive commands.

To remove user

sudo userdel new-username

Sometimes, for example in Ubuntu 20.04, the sudo group is used, in that case use sudo usermod -aG sudo new-username.

Buy Me A Coffee