What are other common useradd options?

QuestionsQuestions8 SkillsProUser Account ManagementNov, 11 2025
073

Here are some common options for the useradd command:

  1. -d: Specify the home directory for the new user.

    sudo useradd -d /path/to/home username
  2. -s: Specify the login shell for the new user.

    sudo useradd -s /bin/bash username
  3. -G: Add the user to supplementary groups.

    sudo useradd -G group1,group2 username
  4. -e: Set an expiration date for the user account.

    sudo useradd -e YYYY-MM-DD username
  5. -r: Create a system account (no home directory is created by default).

    sudo useradd -r username
  6. -p: Set the password for the new user (the password should be encrypted).

    sudo useradd -p encrypted_password username
  7. -m: Create the user's home directory (as previously mentioned).

    sudo useradd -m username

These options can be combined to customize the user creation process according to your needs.

0 Comments

no data
Be the first to share your comment!