Last Updated on May 22, 2022
Create a new user with the command-line
From the command-line, a new user is created using the adduser command. You need elevated privileges to create a user (the user running the command needs to be a member of the sudo group or logged in as root). Here’s an example command:
$ sudo useradd -m joshua
The -m flag gives the new user, joshua, their own home directory, /home/joshua/, which is populated with three hidden files (.bash_logout, .bashrc, and .profile).
We can define the new user’s password with the command:
$ sudo passwd joshua
Enter the password when prompted.
In some cases, it will be useful to add a user to a group (other than their default “main” group) in order to grant them additional permissions. For example, a user who is included in the cdrom group can access CD/DVD and other optical devices. Let’s create a user (ken) with additional permissions.
$ sudo useradd -mG cdrom ken
And give that new user a password in the same way as before:
$ sudo passwd ken
Enter the password when prompted.
We hope this introduction for creating users is useful.
Pages in this article:
Page 1 – Groups
Page 2 – Create a new user with the GUI
Page 3 – Create a new user with the command-line
All articles in this series: