Linux User and Group Management Commands
Overview
Linux provides a set of commands for managing users and groups. These commands allow you to create, modify, delete, and view users and groups on the system. This document covers basic and commonly used user and group management commands.
User Management
adduser
or useradd
Creates a new user.
Example
usermod
Modifies an existing user's account details.
Example
deluser
or userdel
Deletes a user account.
Example
passwd
Changes a user's password.
Example
id
Displays information about a user.
Example
whoami
Displays the username of the current user.
Example
Group Management
addgroup
or groupadd
Creates a new group.
Example
delgroup
or groupdel
Deletes a group.
Example
gpasswd
Modifies group memberships and settings.
Example
groups
Displays the groups that a user belongs to.
Example
View Users and Groups
getent
Displays entries from databases configured in /etc/nsswitch.conf
, including users and groups.
Example
cat /etc/passwd
Displays the contents of the user account database file.
Example
cat /etc/passwd
# Output: Displays user account information including username, UID, GID, home directory, and shell
cat /etc/group
Displays the contents of the group database file.
Example
Summary
Linux offers a range of commands for managing users and groups, including creating, modifying, and deleting accounts and groups. Understanding these commands helps in effectively managing user and group permissions on a Linux system. For more detailed information on each command, refer to the Linux manual pages.