Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
When an admin adds you to a group, your running sessions do not have it yet. newgrp GROUP starts a new shell in which GROUP is your primary group (new files get this group) and the group is active.
If you are not a member, newgrp asks for the group password (if one is set). exit returns to the old shell.
Zo schrijf je het
newgrp [-] [GROUP]Opties 2
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 10
$ als gewone gebruiker# als root (of met sudo)
1Use a new group without a new login
newgrp webadmins id -gn webadminsexitto go back.2Create files with a team group
New files get the primary group sales.
3Check the active groups before and after
The new shell has the group.
4Go back to the normal group
Leaves the newgrp shell.
5Start as a new login
newgrp - salesClean environment, like a new login.
6Run one command with a group (sg)
sg sales -c 'touch /srv/sales/plan.txt'sg = newgrp for one command.
7Join with a group password
newgrp projectx Password:Works only if a group password was set (rare).
8In a script after adding a user to docker or podman groups
newgrp libvirtFor example after
usermod -aG libvirt $USERto use virsh without a new login.9Check the group of new files
Shows which group new files get.
10Best alternative: log in again
A new login gives all groups at once, not only one.
Niets past bij dit filter.
Let op
- newgrp starts a new shell; your old variables and history are not in it.
- A setgid folder (
chmod g+s) is often a better way to give files a team group.
Bestanden
/etc/group, /etc/gshadow- Members and group passwords.
Exitcodes
0 | Done (exit code of the shell). |
1 | Not allowed or the group does not exist. |