linux_wiki:create_delete_and_modify_local_user_accounts

This is an old revision of the document!


Create Delete And Modify Local User Accounts

General Information

About this page/how-to/script.


User IDs

  • 0 = root
  • 1-200 = Red Hat assigned system users
  • 201-999 = Other system users
  • 1000+ = Regular users

User files

  • /etc/passwd - user account details
  • /etc/shadow - user account's hashed password and password age/expiry details

Add user with default settings

useradd rjones
  • Users belong to 1 primary group.
  • Users may belong to many other supplementary groups.

Useradd default settings:

  • /etc/default/useradd

Login default settings

  • /etc/login.defs

User comment, usually for a full name (also known as the GECOS field)

usermod -c "Robert Jones" rjones

Lock user account (user cannot login)

usermod -L rjones
  • Note: This only locks the password from being used. It will not stop passwordless authentication such as public/private keys.
  • Use “usermod -e 1 rjones” to immediately disable the account. (-e = expire date; the date the account will be disabled)

Unlock user account

usermod -U rjones

Stop user from logging into a shell

usermod -s /sbin/nologin rjones

Delete user account

userdel rjones
  • user cannot be logged in
  • -r ⇒ remove user's home directory and all files in it

  • linux_wiki/create_delete_and_modify_local_user_accounts.1456800992.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)