Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

groups

Show the names of the groups a user is in.

Niveau
Dagelijks Linux
Groep
Gebruikers en groepen
Root nodig
Nee
Pakket
coreutils

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

groups prints the group names of the current process, or of the users you name. It is the same as id -Gn. The first name is the primary group.

Zo schrijf je het

groups [OPTION]... [USER]...

Opties 3

Meest gebruikt

USER
Show the groups of this user (more names allowed).
--help
Show help.
--version
Show the version.

Voorbeelden 10

$ als gewone gebruiker# als root (of met sudo)

  1. 1My groups

    groups
    student wheel

    The first is the primary group.

  2. 2Groups of other users

    groups lisa omar
    lisa : lisa webadmins
    omar : omar wheel webadmins

    With names, each line starts with the user.

  3. 3After adding a group

    usermod -aG webadmins student
    groups; groups student
    student wheel
    student : student wheel webadmins

    The shell gets the new group only after a new login.

  4. 4Check admin rights quickly

    groups | grep -qw wheel && echo "you can use sudo"

    wheel = sudo on RHEL.

  5. 5Count the groups of a user

    groups lisa | wc -w

    The output includes the name and the colon for a named user.

  6. 6Use it in a script for many users

    for u in anna bob carol; do groups "$u"; done

    Fast check after a lab.

  7. 7Compare with id

    id -Gn lisa

    Same names, no "lisa :" before them.

  8. 8Check a group for a shared folder

    groups | grep -w sales

    Needed to write in a folder owned by group sales.

  9. 9Check the groups of a service user

    groups apache
    apache : apache

    Service accounts should have as few groups as possible.

  10. 10Find members of the docker or wheel group (audit)

    getent group wheel

    groups shows per user; getent group shows per group.

Exitcodes

0 :: Done. 1 :: A user does not exist.

Volledige handleiding

Deze pagina legt het commando uit in eenvoudige woorden. De originele handleiding heeft elk detail.

In je terminal: man groups