To add a new user account with admin access on Linux, use the useradd
command followed by the -G
option and the group name “sudo” or “admin”. For example:
sudo useradd -m -G sudo newuser
This will create a new user named “newuser” and add them to the “sudo” group, giving them admin access. Next, set a password for the new user:
sudo passwd newuser
You can also use the adduser
command instead of useradd
.
sudo adduser --ingroup sudo newuser
This will add the user to the sudo group and also prompt you to set a password for the new user.