🎓 A1Learner
🔍
0 of 50 lessons completed

Adding Users

useradd makes a new account. The new account gets a name and a user number.

Make a new account

useradd sam makes an account named sam. It prints nothing.

$ useradd sam

Check the new account

id sam prints the numbers for sam. The numbers differ on every machine.

$ id sam

Check its password

passwd --status sam prints one line about the password. The L means locked.

$ passwd --status sam

Example

$ id sam
$ passwd --status sam

Key points

  • Use useradd with a name to make a new account.
  • useradd prints nothing when it works.
  • Use id with a name to print the numbers for that account.
  • passwd --status prints one line about the password of an account.
  • The L in the line means locked.
  • In short, useradd makes the account, and id shows it exists.

In this example, id prints the numbers for sam. The user number is 1001, and the group number is 1001. passwd --status prints the password line next. The L means the account is locked, because it has no password yet.

Note

Only the superuser can add accounts.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What does useradd sam do?