Linux·28 questions

How to safely manage users and groups in Linux?

Answer

Administration of user accounts and groups is a fundamental task for ensuring the security of any Linux system. Proper permission allocation minimizes the risks of unauthorized access and limits potential damage in the event of a compromise of an individual application or service.

To create new users, the useradd utility is used along with the passwd command to set a strong password. Information about all user accounts is stored in the /etc/passwd file, and password hashes are located in the protected /etc/shadow file, accessible only to the root superuser.

Groups allow users to be combined for shared access to files and resources. They are managed using the groupadd and usermod utilities, with the latter also used to add a user to supplementary groups, for example, to grant permissions to run Docker or manage sudo.

Basic user management operations include:

Creating a user while simultaneously creating a home directory using the -m flag.
Setting or changing an account password via the passwd utility.
Adding an existing user to a group using the -aG flag of the usermod utility.
Completely deleting a user along with their home directory using the -r flag of the userdel utility.

Regular auditing of user accounts and timely blocking of unused accesses are an important part of server information security policies.

Was this answer helpful?

More questions in this topic

Related questions from other topics