Create a Linux User
Create a Linux User
Imagine a new school assistant joins the team. Giving them their own Linux account means their identity is separate from the teacher's, and files can have a clear owner. An account has properties such as a numeric user ID, a home path and a configured login shell. It is more than a name you type at a prompt.
We will create a practice account with useradd and inspect its record. Creating it, assigning a password and allowing administrative commands are separate choices. Keeping those choices separate prevents the common mistake of granting much broader access than the assistant needs.
What you’ll learn
- Create a practice account with an explicit home-directory choice.
- Verify its identity and distinguish account creation from granting administrative access.
Identity, home and authorization are separate
Account record
useradd creates an identity with a numeric user ID.
school-assistantHome and shell
Explicit -m and -s options request these account properties.
home + /bin/bashAuthorization
Password setup and sudo policy remain separate decisions.
no automatic admin access
Create and inspect the school assistant account
Prepare the example
Use a disposable Linux VM and an account allowed to administer users. First check whether school-assistant already exists; do not run the create command again on an existing account. The example chooses /bin/bash, so confirm that shell is installed. Account creation changes the VM; it is not something this lesson page performs for you.
Bash · Linux terminal
sudo useradd -m -s /bin/bash school-assistant
getent passwd school-assistantExpected behavior; machine-dependent details
An account record; UID, GID and other defaults vary.In sudo useradd -m -s /bin/bash school-assistant, sudo requests the authorized administrative operation. -m requests creation of a home directory, and -s explicitly selects the shell. Without explicit options, defaults can differ across distributions and local configuration.
getent passwd school-assistant then asks the configured account lookup system for the record. Read the username, numeric IDs, home path and shell rather than expecting a particular ID value. This record is not a password setup step or a grant of sudo rights. Prepare password authentication separately if needed, and inspect the actual home directory instead of assuming the recorded path proves its contents exist.
Choose account properties and verify the new identity
Creating a Linux user usually involves more than adding a username. You may also need a home directory, a login shell, a password and membership in one or more groups.
Open a terminal with administrative access
First things first, open your terminal. If you're on a server, make sure you're logged in as a user with sudo privileges.
Step 2: Use the useradd Command
To create a new user, we'll use the useradd command followed by the username you want to assign. For example, let's create a user named john:
sudo useradd john
But wait! This just creates the user—it does not set a usable password; home-directory creation depends on options and configured defaults. So let’s do that properly using options.
Step 3: Create User with Home Directory
This is an alternative to the preceding creation command, not a second step for the same existing account. In a fresh VM, run only one useradd command. Choose the following form when you want useradd to create a home directory:
sudo useradd -m john
Step 4: Set a Password for the User
Now let’s give our new user a password. This is done using the passwd command:
sudo passwd john
You’ll be prompted to enter and confirm the new password:
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Step 5: Verify the User
To verify that the user was added successfully, you can check the list of users using:
cat /etc/passwd | grep john
john:x:1001:1001::/home/john:/bin/bash
This illustrative record shows the configured home path and shell. Numeric IDs and shell defaults vary. A record alone does not prove the directory exists; verify it with ls -ld /home/john, and use id john to inspect identity and group membership.
Step 6: Optional – Add User to Sudoers Group
If you want your new user to have sudo (admin) privileges, add them to the sudo group:
sudo usermod -aG sudo john
On systems whose sudo policy grants privileges to this group, a new suitable session can use the configured commands. The group name is distribution-specific.
Create a user account and verify it
Check defaults before granting access
When a user-creation example works on one distribution but behaves differently on another, start with the defaults rather than assume you typed the name incorrectly. The home-creation setting, shell and group rules come from configuration as well as explicit options. That is why we selected -m and -s in the main example. Inspect the account with getent, its actual home directory with ls -ld, and its memberships with id.
Administrative access is another decision. Some systems grant a role through a group named sudo, while others use wheel or specific sudo policy rules. The group name alone is not a universal permission grant. Ask which commands the assistant genuinely needs, then use the local policy to authorize that scope rather than make every new account an administrator.
Try it, then check the worked answer
Your task: Does creating an account automatically grant administrative authority?
Use a disposable Linux VM and an account allowed to administer users. First check whether school-assistant already exists; do not run the create command again on an existing account. The example chooses /bin/bash, so confirm that shell is installed. Account creation changes the VM; it is not something this lesson page performs for you.
Bash · complete example for this question
sudo useradd -m -s /bin/bash school-assistant
getent passwd school-assistantExpected behavior; machine-dependent details
An account record; UID, GID and other defaults vary.Worked answer
No; authorization is configured separately.
No automatic administrative authority follows from merely creating an account. A home directory gives the assistant a place for personal files; it does not grant sudo. Administrative authorization depends on the system's policy and relevant group or rule configuration.
Check your decision
Creating an account does not grant administrative access
Create the identity, verify its properties, then make deliberate authentication and authorization choices. Use one creation form for a new username, not several alternative forms in sequence. Explicit home and shell options help make the example predictable while numeric IDs and policy remain system-specific.
Reaching the recap and completing the quizzes are separate milestones.