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 aspect of system administration, ensuring that the right people have the appropriate access to resources. On macOS, this process is streamlined through both graphical interfaces and command-line tools. This article will guide you through the essential steps to manage users and groups on macOS, highlighting the importance of these tasks for system security and organization.

Examples:

Creating a New User via System Preferences

  1. Open System Preferences.
  2. Click on Users & Groups.
  3. Click the lock icon and enter an administrator name and password.
  4. Click the + button below the list of users.
  5. Fill in the new user's details, such as Full Name, Account Name, Password, and Verify.
  6. Click Create User.

Creating a New User via Terminal

You can also create a new user account using the Terminal. This is particularly useful for scripting or remote management.

sudo sysadminctl -addUser newusername -fullName "New User" -password "userpassword"

Creating a New Group via Terminal

To create a new group, use the dseditgroup command:

sudo dseditgroup -o create newgroup

Adding a User to a Group

To add a user to a group, you can use the following command:

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

Listing Users and Groups

To list all users on the system:

dscl . list /Users

To list all groups on the system:

dscl . list /Groups

Deleting a User

To delete a user account via Terminal:

sudo sysadminctl -deleteUser newusername

Deleting a Group

To delete a group:

sudo dseditgroup -o delete newgroup

Modifying User Account Details

To change a user's password:

sudo dscl . -passwd /Users/newusername newpassword

To change a user's shell:

sudo chsh -s /bin/zsh newusername

Practical Use Case

Suppose you need to create a new user for a temporary project and add them to a specific group for access control. You can execute the following commands:

  1. Create the user:

    sudo sysadminctl -addUser tempuser -fullName "Temporary User" -password "temppassword"
  2. Create a project group:

    sudo dseditgroup -o create projectgroup
  3. Add the user to the project group:

    sudo dseditgroup -o edit -a tempuser -t user projectgroup
  4. Verify the user is added to the group:

    dscl . read /Groups/projectgroup

By following these steps, you ensure that the temporary user has the necessary access while maintaining system security and organization.

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.