Determine which group(s) a running process is in?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I try to determine which group(s) a running child process has inherited. I want to find all groups the process is in for his uid. Is there a way to determine this via /proc filesystem?
linux permissions process group proc
add a comment |Â
up vote
3
down vote
favorite
I try to determine which group(s) a running child process has inherited. I want to find all groups the process is in for his uid. Is there a way to determine this via /proc filesystem?
linux permissions process group proc
Are you looking for the groups associated to the process's UID (which one?), or for the groups that the process is in? The two are usually the same, but they might not be (e.g. if the process was run withsudo -g
, or if the group database changed since the user logged in).
â Gilles
May 17 at 15:58
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I try to determine which group(s) a running child process has inherited. I want to find all groups the process is in for his uid. Is there a way to determine this via /proc filesystem?
linux permissions process group proc
I try to determine which group(s) a running child process has inherited. I want to find all groups the process is in for his uid. Is there a way to determine this via /proc filesystem?
linux permissions process group proc
edited May 17 at 20:42
Roger Lipscombe
714620
714620
asked May 17 at 12:07
Mandragor
395210
395210
Are you looking for the groups associated to the process's UID (which one?), or for the groups that the process is in? The two are usually the same, but they might not be (e.g. if the process was run withsudo -g
, or if the group database changed since the user logged in).
â Gilles
May 17 at 15:58
add a comment |Â
Are you looking for the groups associated to the process's UID (which one?), or for the groups that the process is in? The two are usually the same, but they might not be (e.g. if the process was run withsudo -g
, or if the group database changed since the user logged in).
â Gilles
May 17 at 15:58
Are you looking for the groups associated to the process's UID (which one?), or for the groups that the process is in? The two are usually the same, but they might not be (e.g. if the process was run with
sudo -g
, or if the group database changed since the user logged in).â Gilles
May 17 at 15:58
Are you looking for the groups associated to the process's UID (which one?), or for the groups that the process is in? The two are usually the same, but they might not be (e.g. if the process was run with
sudo -g
, or if the group database changed since the user logged in).â Gilles
May 17 at 15:58
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
4
down vote
The list of groups is given under Groups
in /proc/
<pid>/status
; for example,
$ grep '^Groups' /proc/$$/status
Groups: 4 24 27 30 46 110 115 116 1000
The primary group is given under Gid
:
$ grep '^Gid' /proc/$$/status
Gid: 1000 1000 1000 1000
ps
is also capable of showing the groups of a process, as the other answers indicate.
add a comment |Â
up vote
3
down vote
Using ps
:
$ ps -o group,supgrp $$
GROUP SUPGRP
muru adm,cdrom,sudo,dip,www-data,plugdev,lpadmin,mlocate,sambashare,lxd,libvirtd,docker,muru
From man ps
, the output columns used for -o
:
egid EGID effective group ID number of the process as a
decimal integer. (alias gid).
egroup EGROUP effective group ID of the process. This will be
the textual group ID, if it can be obtained and
the field width permits, or a decimal
representation otherwise. (alias group).
gid GID see egid. (alias egid).
group GROUP see egroup. (alias egroup).
supgid SUPGID group ids of supplementary groups, if any. See
getgroups(2).
supgrp SUPGRP group names of supplementary groups, if any. See
getgroups(2).
add a comment |Â
up vote
3
down vote
For the effective group id, real group id and supplementary group ids (as used for access control):
ps -o gid,rgid,supgid -p "$pid"
gid
and rgid
are fairly portable, supgid
less so (all 3 would be available with the ps
from procps as typically found on Linux-based systems).
group
, rgroup
and supgrp
can be used to translate group ids to group names, but note that for group ids that have several corresponding group names, only one of them will be shown (same as for ls -l
vs ls -n
or anything that deals with user or group names based on ids).
For the process group id (as used for terminal job control):
ps -o pgid -p "$pid"
add a comment |Â
up vote
-2
down vote
On a UNIX system derived from SVr4, you may call:
pcred <prcess-id>
Note that the official procfs
is not ASCII but binary.
The question is about Linux, which is not (much) derived from SVr4, so this doesn't answer the question. Also there is no such thing as âÂÂthe official procfsâÂÂ: each Unix variant has its own implementation of it, or doesn't have one.
â Gilles
May 17 at 16:00
You seem to miss that there was a paper on procfs and another one on procfs-2. Linux has not much more in common with that paper than the name procfs. Since this portal is about UNIX, it is obvious that there are people who like to know how things work on UNIX even thought the question might have been Linux specific.
â schily
May 17 at 20:09
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
The list of groups is given under Groups
in /proc/
<pid>/status
; for example,
$ grep '^Groups' /proc/$$/status
Groups: 4 24 27 30 46 110 115 116 1000
The primary group is given under Gid
:
$ grep '^Gid' /proc/$$/status
Gid: 1000 1000 1000 1000
ps
is also capable of showing the groups of a process, as the other answers indicate.
add a comment |Â
up vote
4
down vote
The list of groups is given under Groups
in /proc/
<pid>/status
; for example,
$ grep '^Groups' /proc/$$/status
Groups: 4 24 27 30 46 110 115 116 1000
The primary group is given under Gid
:
$ grep '^Gid' /proc/$$/status
Gid: 1000 1000 1000 1000
ps
is also capable of showing the groups of a process, as the other answers indicate.
add a comment |Â
up vote
4
down vote
up vote
4
down vote
The list of groups is given under Groups
in /proc/
<pid>/status
; for example,
$ grep '^Groups' /proc/$$/status
Groups: 4 24 27 30 46 110 115 116 1000
The primary group is given under Gid
:
$ grep '^Gid' /proc/$$/status
Gid: 1000 1000 1000 1000
ps
is also capable of showing the groups of a process, as the other answers indicate.
The list of groups is given under Groups
in /proc/
<pid>/status
; for example,
$ grep '^Groups' /proc/$$/status
Groups: 4 24 27 30 46 110 115 116 1000
The primary group is given under Gid
:
$ grep '^Gid' /proc/$$/status
Gid: 1000 1000 1000 1000
ps
is also capable of showing the groups of a process, as the other answers indicate.
edited May 17 at 13:07
answered May 17 at 12:13
AlexP
6,616823
6,616823
add a comment |Â
add a comment |Â
up vote
3
down vote
Using ps
:
$ ps -o group,supgrp $$
GROUP SUPGRP
muru adm,cdrom,sudo,dip,www-data,plugdev,lpadmin,mlocate,sambashare,lxd,libvirtd,docker,muru
From man ps
, the output columns used for -o
:
egid EGID effective group ID number of the process as a
decimal integer. (alias gid).
egroup EGROUP effective group ID of the process. This will be
the textual group ID, if it can be obtained and
the field width permits, or a decimal
representation otherwise. (alias group).
gid GID see egid. (alias egid).
group GROUP see egroup. (alias egroup).
supgid SUPGID group ids of supplementary groups, if any. See
getgroups(2).
supgrp SUPGRP group names of supplementary groups, if any. See
getgroups(2).
add a comment |Â
up vote
3
down vote
Using ps
:
$ ps -o group,supgrp $$
GROUP SUPGRP
muru adm,cdrom,sudo,dip,www-data,plugdev,lpadmin,mlocate,sambashare,lxd,libvirtd,docker,muru
From man ps
, the output columns used for -o
:
egid EGID effective group ID number of the process as a
decimal integer. (alias gid).
egroup EGROUP effective group ID of the process. This will be
the textual group ID, if it can be obtained and
the field width permits, or a decimal
representation otherwise. (alias group).
gid GID see egid. (alias egid).
group GROUP see egroup. (alias egroup).
supgid SUPGID group ids of supplementary groups, if any. See
getgroups(2).
supgrp SUPGRP group names of supplementary groups, if any. See
getgroups(2).
add a comment |Â
up vote
3
down vote
up vote
3
down vote
Using ps
:
$ ps -o group,supgrp $$
GROUP SUPGRP
muru adm,cdrom,sudo,dip,www-data,plugdev,lpadmin,mlocate,sambashare,lxd,libvirtd,docker,muru
From man ps
, the output columns used for -o
:
egid EGID effective group ID number of the process as a
decimal integer. (alias gid).
egroup EGROUP effective group ID of the process. This will be
the textual group ID, if it can be obtained and
the field width permits, or a decimal
representation otherwise. (alias group).
gid GID see egid. (alias egid).
group GROUP see egroup. (alias egroup).
supgid SUPGID group ids of supplementary groups, if any. See
getgroups(2).
supgrp SUPGRP group names of supplementary groups, if any. See
getgroups(2).
Using ps
:
$ ps -o group,supgrp $$
GROUP SUPGRP
muru adm,cdrom,sudo,dip,www-data,plugdev,lpadmin,mlocate,sambashare,lxd,libvirtd,docker,muru
From man ps
, the output columns used for -o
:
egid EGID effective group ID number of the process as a
decimal integer. (alias gid).
egroup EGROUP effective group ID of the process. This will be
the textual group ID, if it can be obtained and
the field width permits, or a decimal
representation otherwise. (alias group).
gid GID see egid. (alias egid).
group GROUP see egroup. (alias egroup).
supgid SUPGID group ids of supplementary groups, if any. See
getgroups(2).
supgrp SUPGRP group names of supplementary groups, if any. See
getgroups(2).
answered May 17 at 12:52
muru
33.2k576140
33.2k576140
add a comment |Â
add a comment |Â
up vote
3
down vote
For the effective group id, real group id and supplementary group ids (as used for access control):
ps -o gid,rgid,supgid -p "$pid"
gid
and rgid
are fairly portable, supgid
less so (all 3 would be available with the ps
from procps as typically found on Linux-based systems).
group
, rgroup
and supgrp
can be used to translate group ids to group names, but note that for group ids that have several corresponding group names, only one of them will be shown (same as for ls -l
vs ls -n
or anything that deals with user or group names based on ids).
For the process group id (as used for terminal job control):
ps -o pgid -p "$pid"
add a comment |Â
up vote
3
down vote
For the effective group id, real group id and supplementary group ids (as used for access control):
ps -o gid,rgid,supgid -p "$pid"
gid
and rgid
are fairly portable, supgid
less so (all 3 would be available with the ps
from procps as typically found on Linux-based systems).
group
, rgroup
and supgrp
can be used to translate group ids to group names, but note that for group ids that have several corresponding group names, only one of them will be shown (same as for ls -l
vs ls -n
or anything that deals with user or group names based on ids).
For the process group id (as used for terminal job control):
ps -o pgid -p "$pid"
add a comment |Â
up vote
3
down vote
up vote
3
down vote
For the effective group id, real group id and supplementary group ids (as used for access control):
ps -o gid,rgid,supgid -p "$pid"
gid
and rgid
are fairly portable, supgid
less so (all 3 would be available with the ps
from procps as typically found on Linux-based systems).
group
, rgroup
and supgrp
can be used to translate group ids to group names, but note that for group ids that have several corresponding group names, only one of them will be shown (same as for ls -l
vs ls -n
or anything that deals with user or group names based on ids).
For the process group id (as used for terminal job control):
ps -o pgid -p "$pid"
For the effective group id, real group id and supplementary group ids (as used for access control):
ps -o gid,rgid,supgid -p "$pid"
gid
and rgid
are fairly portable, supgid
less so (all 3 would be available with the ps
from procps as typically found on Linux-based systems).
group
, rgroup
and supgrp
can be used to translate group ids to group names, but note that for group ids that have several corresponding group names, only one of them will be shown (same as for ls -l
vs ls -n
or anything that deals with user or group names based on ids).
For the process group id (as used for terminal job control):
ps -o pgid -p "$pid"
edited May 17 at 12:58
answered May 17 at 12:52
Stéphane Chazelas
279k53513845
279k53513845
add a comment |Â
add a comment |Â
up vote
-2
down vote
On a UNIX system derived from SVr4, you may call:
pcred <prcess-id>
Note that the official procfs
is not ASCII but binary.
The question is about Linux, which is not (much) derived from SVr4, so this doesn't answer the question. Also there is no such thing as âÂÂthe official procfsâÂÂ: each Unix variant has its own implementation of it, or doesn't have one.
â Gilles
May 17 at 16:00
You seem to miss that there was a paper on procfs and another one on procfs-2. Linux has not much more in common with that paper than the name procfs. Since this portal is about UNIX, it is obvious that there are people who like to know how things work on UNIX even thought the question might have been Linux specific.
â schily
May 17 at 20:09
add a comment |Â
up vote
-2
down vote
On a UNIX system derived from SVr4, you may call:
pcred <prcess-id>
Note that the official procfs
is not ASCII but binary.
The question is about Linux, which is not (much) derived from SVr4, so this doesn't answer the question. Also there is no such thing as âÂÂthe official procfsâÂÂ: each Unix variant has its own implementation of it, or doesn't have one.
â Gilles
May 17 at 16:00
You seem to miss that there was a paper on procfs and another one on procfs-2. Linux has not much more in common with that paper than the name procfs. Since this portal is about UNIX, it is obvious that there are people who like to know how things work on UNIX even thought the question might have been Linux specific.
â schily
May 17 at 20:09
add a comment |Â
up vote
-2
down vote
up vote
-2
down vote
On a UNIX system derived from SVr4, you may call:
pcred <prcess-id>
Note that the official procfs
is not ASCII but binary.
On a UNIX system derived from SVr4, you may call:
pcred <prcess-id>
Note that the official procfs
is not ASCII but binary.
answered May 17 at 12:38
schily
8,65421435
8,65421435
The question is about Linux, which is not (much) derived from SVr4, so this doesn't answer the question. Also there is no such thing as âÂÂthe official procfsâÂÂ: each Unix variant has its own implementation of it, or doesn't have one.
â Gilles
May 17 at 16:00
You seem to miss that there was a paper on procfs and another one on procfs-2. Linux has not much more in common with that paper than the name procfs. Since this portal is about UNIX, it is obvious that there are people who like to know how things work on UNIX even thought the question might have been Linux specific.
â schily
May 17 at 20:09
add a comment |Â
The question is about Linux, which is not (much) derived from SVr4, so this doesn't answer the question. Also there is no such thing as âÂÂthe official procfsâÂÂ: each Unix variant has its own implementation of it, or doesn't have one.
â Gilles
May 17 at 16:00
You seem to miss that there was a paper on procfs and another one on procfs-2. Linux has not much more in common with that paper than the name procfs. Since this portal is about UNIX, it is obvious that there are people who like to know how things work on UNIX even thought the question might have been Linux specific.
â schily
May 17 at 20:09
The question is about Linux, which is not (much) derived from SVr4, so this doesn't answer the question. Also there is no such thing as âÂÂthe official procfsâÂÂ: each Unix variant has its own implementation of it, or doesn't have one.
â Gilles
May 17 at 16:00
The question is about Linux, which is not (much) derived from SVr4, so this doesn't answer the question. Also there is no such thing as âÂÂthe official procfsâÂÂ: each Unix variant has its own implementation of it, or doesn't have one.
â Gilles
May 17 at 16:00
You seem to miss that there was a paper on procfs and another one on procfs-2. Linux has not much more in common with that paper than the name procfs. Since this portal is about UNIX, it is obvious that there are people who like to know how things work on UNIX even thought the question might have been Linux specific.
â schily
May 17 at 20:09
You seem to miss that there was a paper on procfs and another one on procfs-2. Linux has not much more in common with that paper than the name procfs. Since this portal is about UNIX, it is obvious that there are people who like to know how things work on UNIX even thought the question might have been Linux specific.
â schily
May 17 at 20:09
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f444351%2fdetermine-which-groups-a-running-process-is-in%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Are you looking for the groups associated to the process's UID (which one?), or for the groups that the process is in? The two are usually the same, but they might not be (e.g. if the process was run with
sudo -g
, or if the group database changed since the user logged in).â Gilles
May 17 at 15:58