User and Group Management

This guide covers user and group management in Linux systems, including creation, modification, and security.

👤 User Management

user and group management in linux

User types

Type
Description
Example

user account

Normal user

username

root

Superuser

root

system account

System user

daemon, ssh

service account

Service user

nginx, mysql

User Information

User Creation and Modification

  • -c - Custom comments

  • -d - Home directory

  • -e - Expiration date

  • -g - Group GID

  • -l - Do not add the user to the lastlog and faillog databases

  • -m - Create the user's home directory

  • -M - Do not create the user's home directory

  • -N - Do not create a group with the same name as the user

  • -o - Allow to create users with duplicate (non-unique) UID

  • -p - Encrypted password of the new account

  • -r - Create a system account

  • -R - Directory to chroot into

  • -P - Prefix directory where are located the /etc/* files

  • -s - Login shell of the new account

  • -u - User ID of the new account

  • -U - Create a group with the same name as the user

  • -Z - Use a specific SEUSER for the SELinux user mapping

Password Management

👥 Group Management

Group Information

Group Creation and Modification

Group Membership

🔐 User Security

Account Security

Sudo Configuration

📁 Home Directory Management

Home Directory Operations

User Files

🔍 System Users and Groups

System Accounts

Special Users

💡 Best Practices

  1. Security

    • Use strong passwords

    • Regular password changes

    • Limit sudo access

    • Audit user accounts

  2. Management

    • Document user creation

    • Regular account review

    • Remove unused accounts

    • Standardize naming

  3. Permissions

    • Use least privilege

    • Regular permission audit

    • Secure home directories

    • Group-based access

🛠️ Advanced Configuration

PAM Configuration

Login Configuration

📊 User Monitoring

Activity Monitoring

Audit Configuration

🔧 Troubleshooting

Common Issues

Account Recovery

Last updated

Was this helpful?