Manage Users, Groups and Passwords in Linux

Manage Users, Groups and Passwords in Linux

Managing users and groups is a fundamental aspect of system administration in Linux, ensuring that access control and permissions are properly maintained. This article will cover the essential concepts of users and groups, gaining superuser access, managing local user accounts, managing local group accounts, and managing user passwords. We will also touch upon password hashing concepts, login policy configurations, tools like chage, and managing password restrictions with pwquality.

Users and Groups Concepts

Users

In Linux, a user is an entity that can perform actions on the system. Each user has a unique user ID (UID) and is associated with a home directory, shell, and other configurations stored in /etc/passwd.

Groups

A group is a collection of users, defined to manage permissions collectively. Each group has a unique group ID (GID) and is listed in /etc/group. Users can belong to multiple groups.

Gaining Superuser Access with sudo

To perform administrative tasks, you need superuser (root) privileges. Instead of logging in as the root user, it’s recommended to use the sudo command to temporarily elevate your privileges.

Manage Local User Accounts

  • Adding a User: To add a new user, use the useradd command followed by passwd to set the password.
  • Modifying a User: The usermod command is used to modify existing user accounts.
  • Deleting a User: To delete a user and their home directory, use the userdel command with the -r option.

Manage Local Group Accounts

  • Adding a Group: To add a new group, use the groupadd command.
  • Modifying a Group: The groupmod command is used to modify existing groups.
  • Deleting a Group: To delete a group, use the groupdel command.

Manage User Passwords

Password Hashing

Passwords in Linux are hashed and stored in /etc/shadow. Common hashing algorithms include MD5, SHA-256, and SHA-512.

Password Policies

Password policies are crucial for enforcing security standards and ensuring that users create strong passwords. These policies can be configured in /etc/login.defs and managed with tools like pwquality.

  • Configuring Password Policies in /etc/login.defs: The /etc/login.defs file defines the configuration for various aspects of user account creation, including password policies.
  • Using chage for Password Aging: The chage command manages user password expiry and aging. It can be used to set password expiry dates, minimum and maximum age, and more.

Enforcing Password Quality with pwquality

The pwquality module enforces password quality requirements, ensuring users create strong passwords that adhere to your security policies. The configuration file for pwquality is /etc/security/pwquality.conf.

  • Installing libpwquality: First, ensure that the libpwquality package is installed:
  • Configuring pwquality: Edit the /etc/security/pwquality.conf file to set your password quality requirements:

With the above configuration, users must create passwords that are at least 12 characters long and include at least one digit, one uppercase letter, one lowercase letter, and one special character. Additionally, no character class can repeat more than three times consecutively.

Examples and Best Practices

Adding a New User with Default Settings

Adding a User to Multiple Groups

Setting Password Expiration Policy

Configuring Strong Password Policies

Edit /etc/login.defs:

Edit /etc/security/pwquality.conf:

Proper management of users and groups is critical for system security and efficiency in Linux. By understanding and implementing the concepts discussed, you can ensure that your system is secure and that users have appropriate access. Regularly reviewing and updating password policies, managing user accounts, configuring group permissions, and enforcing strong password quality will help maintain a well-organized and secure system.

Leave a Reply

WordPress Appliance - Powered by TurnKey Linux