User Management

Add a user to a group

Price range: €18.64 through €26.12

Command:

bash
sudo usermod -aG {group_name} {username}

Explanation:

  • sudo: Runs the command with superuser privileges, as modifying user groups typically requires root access.
  • usermod: A command used to modify a user’s account settings.
  • -aG: The -a option appends the user to the specified group(s), and the -G option specifies the group(s) to which the user will be added.
  • {group_name}: The name of the group you want to add the user to (e.g., sudodevelopers).
  • {username}: The username of the user you want to add to the group (e.g., johnalice).

Example:

To add the user john to the group sudo, the command would be:

bash
sudo usermod -aG sudo john

Result:

This command will add the user john to the sudo group, allowing them to execute commands with elevated privileges if required.


Additional Notes:

  • After adding a user to a group, the user will typically need to log out and back in for the group changes to take effect.
  • To verify that the user has been added to the group, you can use the groups command:
    bash
    groups {username}

    For example:

    bash
    groups john
Select options This product has multiple variants. The options may be chosen on the product page

Change a user’s password

Price range: €18.18 through €24.12

Command:

bash
sudo passwd {username}

Explanation:

  • sudo: Runs the command with superuser privileges, which are required to change the password for another user.
  • passwd: The command used to change a user’s password.
  • {username}: The username of the account whose password you wish to change. Replace {username} with the actual username (e.g., johnalice).

Example:

To change the password for the user john, the command would be:

bash
sudo passwd john

Result:

After executing the command, you will be prompted to enter the new password for the specified user. The password will need to be confirmed by entering it again.


Additional Notes:

  • If you are changing your own password (the user you’re logged in as), you can simply use:
    bash
    passwd
  • Passwords in Linux are typically stored in an encrypted format for security.
  • Ensure the new password meets the system’s password policies (e.g., minimum length, complexity).
Select options This product has multiple variants. The options may be chosen on the product page