NEWGIDMAP(1)

๐Ÿ’– NEWGIDMAP โ€” bestie edition ๐Ÿ’–

okay so <rainbow>newgidmap</rainbow> is a lil user command from the shadow-utils fam, and its whole job is: set the gid mapping of a user namespace. that's it. that's the vibe. ๐Ÿซถ


โœจ SYNOPSIS โœจ

newgidmap pid gid lowergid count [gid lowergid count [ ... ]]

๐ŸŒธ DESCRIPTION ๐ŸŒธ

so newgidmap sets /proc/[pid]/gid_map based on the stuff you typed on the command line and the gids that are allowed. and here's the tea โ˜• โ€” subgid delegation can be managed either via /etc/subgid or through the configured NSS subid module. those two options? mutually exclusive, periodt. pick one, not both, bestie.

โš ๏ธ also note: the root group is NOT exempted from the requirement for a valid /etc/subgid entry. like, not even root gets a free pass. iconic? maybe. strict? absolutely. ๐Ÿ’…

after the pid argument, newgidmap expects sets of 3 integers:

  • gid โ€” the beginning of the range of GIDs inside the user namespace ๐ŸŽ€
  • lowergid โ€” the beginning of the range of GIDs outside the user namespace ๐Ÿฆ‹
  • count โ€” the length of the ranges (both inside and outside the user namespace, yes both, she's doing double duty) โญ

then newgidmap does a lil vibe check ๐Ÿ”: it verifies that the caller is the owner of the process indicated by pid, and that for each of the above sets, every single GID in the range [lowergid, lowergid+count) is allowed to the caller according to /etc/subgid โ€” all of that before it sets /proc/[pid]/gid_map.

๐Ÿ˜ญ and heads up: newgidmap may be used only once for a given process. one shot. no takebacks. no reruns. choose wisely bestie.

๐Ÿงš the fd:N glow-up (TOCTTOU protection, we love to see it)

instead of an integer process id, that first argument can be specified as fd:N, where the integer N is the file descriptor number for the calling process's opened file descriptor for the directory /proc/[pid]. ๐Ÿ™ˆ

in that case, newgidmap will use openat(2) to open the gid_map file under that directory โ€” which avoids a TOCTTOU in case the process exits and the pid is immediately reused. race condition? not on her watch. ๐Ÿ”ฅ


๐Ÿ’… OPTIONS ๐Ÿ’…

  • there currently are no options to the newgidmap command.

like literally none. she's lowkey a minimalist. no flags, no frills, just vibes and integers. โœจ


๐Ÿ“ FILES ๐Ÿ“

  • /etc/subgid โ€” list of user's subordinate group IDs. ๐Ÿ“‹
  • /proc/[pid]/gid_map โ€” mapping of gids from one between user namespaces. ๐Ÿ—บ๏ธ

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

login.defs(5), newusers(8), subgid(5), useradd(8), userdel(8), usermod(8).

go read those too, they're the supporting cast and they ate. ๐Ÿ’œ


and that's the whole page bestie!! ๐ŸŒˆ this was brought to you by shadow-utils 4.20.0, dated 07/30/2026 โ€” so you know it's fresh, it's current, and it's giving main character energy. mwah ๐Ÿ’–๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from