User and group management (creation, modification, deletion) – User and Group Administration – Linux operating system

User and group management is an essential aspect of Linux system administration. It involves creating, modifying, and deleting user accounts and groups. Here’s an overview of user and group management in Linux:

User Management:

  1. Creating a User:
    • To create a new user, you can use the useradd command followed by the username.
    • Example: sudo useradd username
    • By default, the useradd command creates a user with minimal settings. Use additional options to specify custom settings like home directory, default shell, etc.
  2. Setting a Password:
    • To set a password for a user, use the passwd command followed by the username.
    • Example: sudo passwd username
    • You will be prompted to enter and confirm the new password.
  3. Modifying User Attributes:
    • Use the usermod command to modify user attributes.
    • Example: sudo usermod -s /bin/bash username
    • Common attributes that can be modified include the user’s shell, home directory, user ID (UID), and group associations.
  4. Deleting a User:
    • To delete a user account, use the userdel command followed by the username.
    • Example: sudo userdel username
    • By default, the userdel command removes the user’s home directory. Use the -r option to also delete the home directory.

Group Management:

  1. Creating a Group:
    • To create a new group, use the groupadd command followed by the group name.
    • Example: sudo groupadd groupname
  2. Modifying Group Attributes:
    • Use the groupmod command to modify group attributes.
    • Example: sudo groupmod -n newgroupname groupname
    • Common attributes that can be modified include the group name and group ID (GID).
  3. Deleting a Group:
    • To delete a group, use the groupdel command followed by the group name.
    • Example: sudo groupdel groupname

Additional User and Group Management Tasks:

  1. Adding a User to a Group:
    • Use the usermod command with the -aG option to add a user to a group.
    • Example: sudo usermod -aG groupname username
    • The -a option ensures that the user is added to the group without removing them from their existing groups.
  2. Listing Users and Groups:
    • To view a list of existing users, use the cat /etc/passwd command.
    • To view a list of existing groups, use the cat /etc/group command.

Proper user and group management is crucial for maintaining system security, access control, and resource allocation in Linux. It’s important to ensure that users have appropriate permissions and are assigned to the correct groups to perform their intended tasks.

SHARE
By John

Leave a Reply

Your email address will not be published. Required fields are marked *

No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.