Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Manage Users & Groups on macOS

Managing users and groups is a fundamental task for any system administrator. On macOS, this can be done through both graphical user interfaces and command-line tools. This article will guide you through the process of creating, modifying, and deleting users and groups on macOS using the Terminal.

Creating a New User

To create a new user on macOS, you can use the sysadminctl command. This command allows you to manage user accounts directly from the Terminal.

Example:

sudo sysadminctl -addUser newuser -fullName "New User" -password "password123"

This command creates a new user with the username newuser, full name "New User", and password "password123".

Creating a New Group

To create a new group, you can use the dseditgroup command.

Example:

sudo dseditgroup -o create newgroup

This command creates a new group named newgroup.

Adding a User to a Group

To add a user to a group, you can use the dseditgroup command as well.

Example:

sudo dseditgroup -o edit -a newuser -t user newgroup

This command adds the user newuser to the group newgroup.

Deleting a User

To delete a user, you can use the sysadminctl command.

Example:

sudo sysadminctl -deleteUser newuser

This command deletes the user newuser.

Deleting a Group

To delete a group, you can use the dseditgroup command.

Example:

sudo dseditgroup -o delete newgroup

This command deletes the group newgroup.

Listing Users and Groups

To list all users on the system, you can use the dscl command.

Example:

dscl . list /Users

To list all groups on the system, you can also use the dscl command.

Example:

dscl . list /Groups

Modifying User Information

To modify user information, such as changing the full name, you can use the dscl command.

Example:

sudo dscl . -change /Users/newuser RealName "New User" "Updated User"

This command changes the full name of the user newuser from "New User" to "Updated User".

Changing User Password

To change a user's password, you can use the passwd command.

Example:

sudo passwd newuser

You will be prompted to enter and confirm the new password for the user newuser.

Practical Use Case

Imagine you are setting up a new macOS machine for a new employee. You need to create a user account for them, add them to the appropriate groups, and set up their initial password.

Steps:

  1. Create the user account:
    sudo sysadminctl -addUser johndoe -fullName "John Doe" -password "initialPassword"
  2. Create a group for the department:
    sudo dseditgroup -o create marketing
  3. Add the user to the group:
    sudo dseditgroup -o edit -a johndoe -t user marketing
  4. Change the user's password to something more secure:
    sudo passwd johndoe

By following these steps, you ensure that the new employee has a user account, is part of the relevant department group, and has a secure password.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.