Users
The newgrp command
Changes the active group of your session by opening a new shell with that group.
Most useful options
-Reinitializes the environment as if you had logged in again. Without it, the working directory is keptCopy-ready examples
$ newgrp sudoswitches your active group to sudo, if you are a member.$ newgrpwith no arguments, returns to the primary group listed in /etc/passwd.$ newgrp - sudochanges group and reinitializes the environment, like a new login.$ sudo usermod -aG equipo alumno && newgrp equipoadds alumno to the equipo group, which must exist first (groupadd), without removing its other groups, and activates it in the session.You can try them in the browser terminal: it does not touch your computer.
Common errors
| Message | Cause | Fix |
|---|---|---|
| newgrp: group 'equipo' does not exist | The name is not in /etc/group: usually a typo or a group you have not created yet. | Check the name with getent group equipo and, if it does not exist, create it with sudo groupadd equipo. |
| Invalid password. | You are not a member of the group, it has a password, and the one you typed is wrong. | Ask the group administrator for the group password, or ask them to add you with usermod -aG. |
Typical mistakes
- newgrp opens a new shell: in newgrp equipo && groups, groups only runs when you exit that shell.
- If you are not a member and the group has no password, newgrp denies access even though the group exists.
- If the group has an entry in /etc/gshadow, its members and password come from that file, not from /etc/group.
Differences from similar commands
FAQ
Why is usermod not enough?
usermod changes the account's group list, while newgrp adds the group to the current session without waiting for a new login.
How do I go back to the previous group?
Type exit: it closes the shell newgrp opened and returns you to the previous one, with its group.
Do I need a password to switch groups?
If you are already a member, no. If you are not and the group has a password, newgrp will ask for it.
Learn to actually use it
The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.
Start the free course