cmdxray / commands / useradd

What does useradd do?

create a new user account.

▸ Explain your own useradd command →

useradd examples, explained

$ useradd -m -s /bin/bash alice

  • useraddcreate a new user account
  • -mcreate the user's home directory
  • -slogin shell for the account
  • /bin/bashvalue for -s
  • alicean argument passed to the command

$ useradd -r -s /usr/sbin/nologin svc

  • useraddcreate a new user account
  • -rcreate a system account (low UID, no aging)
  • -slogin shell for the account
  • /usr/sbin/nologinvalue for -s
  • svcan argument passed to the command

$ useradd -m -G sudo,docker bob

  • useraddcreate a new user account
  • -mcreate the user's home directory
  • -Gsupplementary groups, comma-separated
  • sudo,dockervalue for -G
  • boban argument passed to the command

useradd flags & options

-mcreate the user's home directory
-Mdo not create a home directory
-rcreate a system account (low UID, no aging)
-slogin shell for the account
-dhome directory path
-gprimary group (name or GID)
-Gsupplementary groups, comma-separated
-uspecific numeric user ID
-ccomment / full-name (GECOS) field
-eaccount expiration date (YYYY-MM-DD)
-ppre-encrypted password (not plain text)
-kskeleton directory to copy into the new home
-Ndo not create a group with the same name as the user
--systemcreate a system account
--create-homecreate the home directory
--shelllogin shell for the account
--home-dirhome directory path
--groupssupplementary groups, comma-separated

Other commands

Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.