Managing User Accounts - Paiet/Tech-Journal-for-Everything GitHub Wiki
- Requirements
- Username
- Everything else is optional
- Full name
- Password
- Home directory
- Default shell
- Creating users:
useradd <username>
useradd -d <homedir> -e <expiredate> -g <defaultgroup> -G <group1,group2,etc> -p <password> -s <shell> -u <UID> <username>
- Modifying a user account
-
userdel <username>
- Use
-r
to remove their files as well
-
usermod
- Rename account:
usermod -l jdoe jsmith
- Lock account:
usermod -L jdoe
- Unlock account:
usermod -U jdoe
- Add user to group:
usermod -a -G Marketing
- Set password:
passwd <username>
-
chage <username>
(Define password expiration policy)
- Display current info:
chage -l jdoe
- Modify policy:
chage -m <mindays> -M <maxdays> -E <expiredate> -W <warndays> jdoe
- Default values:
/etc/login.defs
/etc/default/useradd
/etc/skel
- Viewing account details
-
/etc/passwd
- Defines accounts
- User ID
- UIDs typically start at 500
- Users/Groups can share an ID (not ideal)
/etc/shadow
- Getting information
sudo getent passwd <user>
sudo getent shadow <user>
⚠️ **GitHub.com Fallback** ⚠️