Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
Wat het doet
Without a name id shows the data of the current process: the user and the groups that are active now. With a name it reads the account data, so it already shows new groups that the logged-in user does not have yet.
With SELinux on, id without a name also shows the security context.
Zo schrijf je het
id [OPTION]... [USER]...Opties 10
Meest gebruikt
Niets past bij dit filter.
Voorbeelden 11
$ als gewone gebruiker# als root (of met sudo)
1Your own IDs
id uid=1000(student) gid=1000(student) groups=1000(student),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023You are in wheel, so you may use sudo.
2Another user
id lisa uid=1001(lisa) gid=1001(lisa) groups=1001(lisa),1100(webadmins)Check new group memberships here.
3Only the UID
id -u 1000In scripts:
[ "$(id -u)" -eq 0 ]tests for root.4Only the user name
id -un studentSame as whoami.
5All group names
id -Gn lisa lisa webadminsEasy to grep.
6Check if a user is in a group
-w matches the whole word only.
7See the SELinux context
id -Z unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023Shows the SELinux user, role and type of your shell.
8Real and effective user
sudo sets both to root. Programs with setuid only change the effective ID.
9Compare the active groups with the account
id -Gn; id -Gn $USERWhen the second list is longer, log in again (or use newgrp).
10Check the user of a container
podman run --rm registry.access.redhat.com/ubi10/ubi id uid=0(root) gid=0(root) groups=0(root)Root in a container: check it in a security review.
11Check a service account
id apache uid=48(apache) gid=48(apache) groups=48(apache)A system account (UID under 1000).
Niets past bij dit filter.
Tips om te onthouden
- id USER = account data. id = what your shell has now.
Exitcodes
0 | Done. |
1 | The user does not exist or another error. |