Y
Y
Yrets1692021-10-22 18:09:42
linux
Yrets169, 2021-10-22 18:09:42

How to display all groups (users) that are in the OS (ubuntu)?

Good afternoon, I'm trying to display all the groups that are in Linux OS

import os,grp,pwd

#выводит пользователя
#for p in pwd.getpwall():
 #   print (p[0])
 
#таким образом выводит группы только для конкретного юзера   
for g in grp.getgrnam('asterisk'):
    print (g)


The script displays groups only for a specific user, how to display all the groups that are in the OS?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2021-10-22
@Yrets169

https://docs.python.org/3/library/grp.html#grp.getgrall
grp.getgrall()

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question