Skip to content

Instantly share code, notes, and snippets.

@scsibug
Last active June 8, 2020 02:35
Show Gist options
  • Save scsibug/0dfa8d7474ccaf2fe17d506b50ed9fd7 to your computer and use it in GitHub Desktop.
Save scsibug/0dfa8d7474ccaf2fe17d506b50ed9fd7 to your computer and use it in GitHub Desktop.
Linux Service Account Creation
useradd username \
--system \
--shell /bin/nologin \
--comment "Description of account" \
--expiredate 1 # block all authentication \
--create-home # or --no-create-home \
--home /home/dir
# Or, short version (w/ home directory)
useradd username -r -s /bin/nologin -c "description" -e 1 -m -d /home/dir
# No home directory
useradd username -r -s /bin/nologin -c "description" -e 1 -M
# Resulting entry in /etc/passwd
username:x:998:997:Description of account:/home/username:/bin/nologin
# Resulting entry in /etc/shadow (password already locked)
username:!:18420::::::
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment