Tips

List All The Groups In Linux

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:

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:

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 CTRL + ALT + T. If that doesn’t work, find the terminal in your application menu and click it.

With your terminal open, run the following command:

getent group

While not of much use, here’s an example output:

$ 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.

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:

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.

KGIII

Retired mathematician, residing in the mountains of Maine. I may be old and wise, but I am not infallible. Please point out any errors. And, as always, thanks again for reading.

Recent Posts

Enable/Disable Your Network Interface

Today we'll cover one way to enable or disable your network interface in the Linux…

4 weeks ago

Check Your NIC Speed In The Terminal

Today's exercise is a nice and simple exercise where we check your NIC speed in…

4 weeks ago

Easily Monitor Your Wireless Connection

Have you ever wanted to easily monitor your wireless connection? Well, now you can learn…

4 weeks ago

Count The Files In A Directory

I think I've covered this before with the ls command but this time we'll count…

1 month ago

Get System Information With The ‘uname’ Command In Linux

Today we'll be learning about a basic Linux command that's known as 'uname' and it…

1 month ago

hardinfo Has Been Rebooted As hardinfo2

If you've used hardinfo in the past, it may interest you to know that hardinfo…

1 month ago