Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
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.
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.
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".
To create a new group, you can use the dseditgroup
command.
sudo dseditgroup -o create newgroup
This command creates a new group named newgroup
.
To add a user to a group, you can use the dseditgroup
command as well.
sudo dseditgroup -o edit -a newuser -t user newgroup
This command adds the user newuser
to the group newgroup
.
To delete a user, you can use the sysadminctl
command.
sudo sysadminctl -deleteUser newuser
This command deletes the user newuser
.
To delete a group, you can use the dseditgroup
command.
sudo dseditgroup -o delete newgroup
This command deletes the group newgroup
.
To list all users on the system, you can use the dscl
command.
dscl . list /Users
To list all groups on the system, you can also use the dscl
command.
dscl . list /Groups
To modify user information, such as changing the full name, you can use the dscl
command.
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".
To change a user's password, you can use the passwd
command.
sudo passwd newuser
You will be prompted to enter and confirm the new password for the user newuser
.
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.
sudo sysadminctl -addUser johndoe -fullName "John Doe" -password "initialPassword"
sudo dseditgroup -o create marketing
sudo dseditgroup -o edit -a johndoe -t user marketing
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.