• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • VCS
  • Interview Questions
  • Database
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

adduser Command Examples in Linux

by admin

To add new users you can use the adduser command. With no options, adduser steps you through the information you need to enter to add a user account. Here’s an example of using adduser to add a user interactively:

# adduser                ### Start an interactive session to add a user
Username: geek
Full name: geek labuser
Uid (Leave empty for default):
Login group [geek]:
Login group is geek. Invite geek into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash ksh nologin) [sh]: bash
Home directory [/home/geek]:
Use password-based authentication? [yes]:
Use an empty password? (yes/no) [no]:
Use a random password? (yes/no) [no]:
Enter password: *********
Enter password again: *********
Lock out the account after creation? [no]:

The user name must be from one to 16 characters. Most people use lowercase letters and digits, with the first character being a letter. Default user IDs (Uid) start at 1001. The default group is a new group with the same name as the user name.

Login class is something that not all UNIX-like systems have. The default class is best for regular users (more on login classes a bit later). Password-based authentication (yes) is the normal authentication. Select a good password (more on passwords later as well).

adduser Command Examples in Linux

1. To add a new user:

# adduser mike

2. To add new user with default directory:

# adduser -d /mike mike

3. To add new user with some comment:

# adduser -c "Admin Group" mike

4. To add new user with expiry date:

# adduser -e 12/12/2015 mike

5. To add new user with primary group:

# adduser -g support mike

6. To add user with supplementary group:

# adduser -G admin mike

7. To add user without home directoy:

 # adduser -M mike

8. Add user without creating default group with same name:

# adduser -N mike

9. To add user with given password:

# adduser -p "12asd124123Ads43" mike

10. To create a system account:

# adduser -r mike

11. To add user with default login shell:

# adduser -s /bin/bash mike

12. To add user with creating group of same name:

# adduser -U mike

The adduser command has many command-line options. The command can be used to set policies and dates for the new user’s password, assign a login shell, assign group membership, and other aspects of a user’s account. See man page for adduser command for more info.

Filed Under: Linux

Some more articles you might also be interested in …

  1. ansible-vault – Encrypts & decrypts values, data structures and files within Ansible projects
  2. How to Clone Linux disk partition over network using dd
  3. Linux OS Service ‘rusersd’
  4. git check-ignore: Analyze and debug Git ignore / exclude (“.gitignore”) files
  5. iotop Command Examples in Linux
  6. “docker compose” Command Examples
  7. Time to live exceeded ping error
  8. httpie Command Examples in Linux
  9. Linux OS Service ‘hplip’
  10. printf: command not found

You May Also Like

Primary Sidebar

Recent Posts

  • Vanilla OS 2 Released: A New Era for Linux Enthusiasts
  • mk Command Examples
  • mixxx Command Examples
  • mix Command Examples

© 2025 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright