AI Hints
Home›Linux Tutorial›Managing Users
Linux · Lesson 71 of 120

Adding Users

Useradd and passwd.

⏱ 2 min read▶ Video at 1:33:21🎓 Free
Watch this lesson in the Linux courseWatch on YouTube ↗Full Linux course

A new teammate, Jo, needs an account on the team's Linux server. Creating users is an admin job, so it needs sudo. Let's set Jo up.

Adding Users
From the video: Adding Users
  • A new teammate, Jo
  • Needs an account
  • An admin job

Creating the account

Sudo user add, dash M, dash S, slash bin slash bash, jo. Dash M creates Jo's home folder, and dash S sets the shell to bash. Then ID jo shows the new user and their groups, and LS shows Jo's home folder.

Terminal
sudo useradd -m -s /bin/bash jo
id jo
uid=1002(jo) gid=1002(jo) groups=1002(jo)
ls /home
alex  jo  sam

Setting a password

The new account has no password yet. Sudo passwd jo sets one. It asks twice, to catch typos. Notice that nothing appears while you type a password. No stars, no dots. That's normal on Linux, and it hides even the length of the password.

Terminal
sudo passwd jo
New password:
Retype new password:
passwd: password updated successfully

Other user commands

A few more commands for managing users. User mod changes an existing user, for example adding them to a group. User del removes a user, and dash R removes their home folder too. And passwd on its own lets you change your own password.

keyvalue
useradd -m -screate a user
passwd userset their password
usermod -aGadd to a group
userdel -rremove a user

Summary

Sudo user add creates an account, and sudo passwd sets its password. Typed passwords stay invisible. Next, groups for teamwork.

Key takeaways
  • sudo useradd -m -s /bin/bash jo
  • sudo passwd jo
  • userdel -r
Next up: Groups for Teamwork — a shared folder