This is going to be a simple enough article where we list all the groups in Linux – specifically your Linux. (Your list of groups may not be the same as my list of groups, of course.) This isn’t complicated but might be important to some of you, so we might as well write about it.
I’ve often mentioned that Linux is a true multi-user operating system. That is, you have many users, each with assigned tasks and permissions. You have users for everything from root to printing.
Well, along those same lines, Linux also uses groups. You can not only set permissions on a per-user basis, you can set permissions on a per-group basis. Any member belonging to that group will have the same permissions as that group.
A good example is ‘sudo‘. That’s a group you likely belong to. Because you belong to the sudo group you have access to the sudo command. This lets you have elevated permissions to perform various operations on your system. Make sense?
We’ll be using a new tool for this…
getent:
The getent command is used to read various databases. This is fine because ‘groups’ is one of the databases that getent can read. You won’t need to install anything to run this command.
You can check the man page with this command:
1 | man getent |
From there, you’ll see that getent is described like so:
getent – get entries from Name Service Switch libraries
So, it’s a database reading tool more than anything else.
If you’d like an easier way, we’ll do the same with the cat command.
cat:
I really shouldn’t have to describe the cat command. We’ve used it plenty of times. It takes the contents of a file and spits them out to your terminal (standard output). It’s an oft-used tool in the Linux world. Once again, you won’t have to install anything.
You can check the man page with this command:
1 | man cat |
At that point, you’ll see that the cat command is described like this:
cat – concatenate files and print on the standard output
See? It’s the correct tool for the job. We want to take the contents of a file and read it in the terminal. The cat command is perfect for that.
I’ll show you how to list all the groups in Linux with both commands. You can pick your favorite and just use that command. Either command will work just fine for this job.
List All The Groups In Linux:
If it wasn’t obvious from the above, this is yet another task for the terminal. If you don’t have an open terminal, you can probably open one by pressing
With your terminal open, run the following command:
1 | getent group |
While not of much use, here’s an example output:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | $ getent group root:x:0: daemon:x:1: bin:x:2: sys:x:3: adm:x:4:syslog,kgiii tty:x:5: disk:x:6: lp:x:7: mail:x:8: news:x:9: uucp:x:10: man:x:12: proxy:x:13: kmem:x:15: dialout:x:20: fax:x:21: voice:x:22: cdrom:x:24:kgiii floppy:x:25: tape:x:26: sudo:x:27:kgiii audio:x:29:pulse dip:x:30:kgiii www-data:x:33: backup:x:34: operator:x:37: list:x:38: irc:x:39: src:x:40: gnats:x:41: shadow:x:42: utmp:x:43: video:x:44: sasl:x:45: plugdev:x:46:kgiii staff:x:50: games:x:60: users:x:100: nogroup:x:65534: systemd-journal:x:101: systemd-network:x:102: systemd-resolve:x:103: crontab:x:104: messagebus:x:105: systemd-timesync:x:106: input:x:107: sgx:x:108: kvm:x:109: render:x:110: syslog:x:111: tss:x:112: rtkit:x:113: systemd-coredump:x:114: lpadmin:x:115:kgiii bluetooth:x:116: ssl-cert:x:117: netdev:x:118: uuidd:x:119: lightdm:x:120: nopasswdlogin:x:121: tcpdump:x:122: _ssh:x:123: plocate:x:124: avahi-autoipd:x:125: nm-openvpn:x:126: geoclue:x:127: pulse:x:128: pulse-access:x:129: scanner:x:130:saned _flatpak:x:131: avahi:x:132: saned:x:133: colord:x:134: fwupd-refresh:x:135: kgiii:x:1000: sambashare:x:136:kgiii sssd:x:137: vboxusers:x:138:kgiii vnstat:x:139: |
You can get the same output with the cat command. That might be easier to remember for newer users. After all, you should be familiar with the cat command. That command is simple enough.
1 | cat /etc/group |
That will give you the same results as the ‘getent’ command above. Obviously, the group name is the first column.
I’m not sure where I learned this, but you can just list the first field and get a list of groups without any additional information. Just use this command:
1 | cut -d: -f1 /etc/group |
That’s not nearly as useful as it could be, but I figured I’d share.
Closure:
Well, if you wanted to list all the groups in Linux, you now know how to do so. If you didn’t know about groups, you now know that you have groups and how to list them. So, you might as well add that to your notes and keep it in mind. (The groups subject may appear in a future article!)
Thanks for reading! If you want to help, or if the site has helped you, you can donate, register to help, write an article, or buy inexpensive hosting to start your site. If you scroll down, you can sign up for the newsletter, vote for the article, and comment.