The sudo
command provides privileges that only the root
account has. In this article, I will guide you to create a Linux User and assign it using the sudo
command on Ubuntu 22.04/Debian.
Step 1: Create <new_user> account with adduser
command:
adduser <new_user>
On Ubuntu/Debian, you don’t need to use passwd
command to set password for new user, the adduser
command will ask you to type new password for the new user shortly after.
Example: Create new linuxtutorials account:
[email protected]:~# adduser linuxtutorials Adding user `linuxtutorials' ... Adding new group `linuxtutorials' (1001) ... Adding new user `linuxtutorials' (1001) with group `linuxtutorials' ... Creating home directory `/home/linuxtutorials' ... Copying files from `/etc/skel' ... New password: Type New password Retype new password: Re-type New password passwd: password updated successfully Changing the user information for linuxtutorials Enter the new value, or press ENTER for the default Full Name []: [Press Enter] Room Number []: [Press Enter] Work Phone []: [Press Enter] Home Phone []: [Press Enter] Other []: [Press Enter] Is the information correct? [Y/n] y
Step 2: Assign the <new_user> account to the sudo group also using the adduser
command.
adduser <new_user> sudo
Step 3: Switch login with new account to check
su - <new_user>
sudo ls -la