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

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • 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. How to add Swap Space on Linux Servers (CentOS/RHEL) On the Fly
  2. Input/Output Errors During XFS Filesystem Access In CentOS/RHEL 7
  3. restorecon Command Examples in Linux
  4. How to recreate LVM device files under /dev directory using vgmknodes
  5. spectre-meltdown-checker Command Examples in Linux
  6. How to Display Routing Table in Linux
  7. bmon Command Examples in Linux
  8. Understanding Variables in Bash Shell Under Linux
  9. imgp: command not found
  10. How to change the PATH variable in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • “aws s3 mv” Command Examples
  • “aws s3 mb” Command Examples
  • “aws s3 ls” Command Examples
  • “aws s3 cp” Command Examples

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright