Run a shell under a different primary group so newly created files and commands inherit that group. 07.06.2026 | reading time: 2 min Want files to land in a different group without logging out? The `newgrp` command replaces the current shell with one running under a new primary group, so subsequent files and processes inherit that group; this short guide shows how and when to use it. Try it now Run this small lab as root and then as user "alex" to see `newgrp` in action: ```bash # groupadd devteam # gpasswd -A alex devteam $ su - alex $ id uid=1001(alex) gid=1000(staff) groups=1000(staff),1002(devteam) $ newgrp devteam $ id uid=1001(alex) gid=1002(devteam) groups=1000(staff),1002(devteam) $ touch project.txt $ ls -l project.txt -rw-r--r-- 1 alex devteam 0 Jun 07 12:00 project.txt ``` Caveats and tactics Note that `newgrp` spawns a subshell with the new primary group, so scripts that expect the parent shell to change will not see the effect; a leading dash `newgrp - group` invokes a login-style shell, root bypasses membership checks, and some systems still require a group password configured with `gpasswd` for locked groups. When to reach for it Use `newgrp` when working interactively in a shared project directory that relies on group ownership or when testing SGID directory behavior; do not use it to permanently alter account groups — prefer proper group membership changes plus a fresh login for lasting effects. Complementary commands Check and debug group context with `id` and `groups`, alter file group ownership with `chgrp`, manage group membership and passwords with `gpasswd`, and use ACLs with `setfacl` when more granular control is needed. A clear next step Practice switching groups in a safe test user and experiment with SGID directories to see permission inheritance, then expand knowledge across Linux permission tooling and consider formal certification for deeper mastery. Join Bits & Bytes Academy First class LINUX exam preparation. utilities security processes filesystem