Use sg to execute a single command or a shell with another primary group to access group protected resources. 08.06.2026 | reading time: 2 min Need quick access to resources owned by a group he belongs to The sg command lets him run one command or start a shell with the primary group set to a chosen group, so files and sockets protected by that group become accessible. Working example See it in action, first check groups then run a command under the docker group ```bash $ id -nG users sudo $ sg docker -c "id -nG; echo inside sg" users docker inside sg ``` Options and caveats Use -c to pass a single command, or omit -c to get an interactive shell; the group argument accepts a name or numeric id; sg requires that he be a member of the target group, and it is simpler for scripting than switching sessions permanently; be aware that environment and umask can differ from a full login shell, so test file creation and permission behavior. Tools that join sg For changing group context or elevating access consider newgrp for switching primary group in a session, sudo for privilege elevation, and setfacl for fine grained file permissions. Close and next steps sg is small and precise, ideal when he needs just one command to run with a different group instead of changing the whole session; practice on a test account and then explore related tools to build reliable workflows; consider deepening Linux skills and pursuing CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. utilities security processes