Languages
[Edit]
EN

Linux - list available groups in Bash

6 points
Created by:
Shri
8550

In this article, we're going to have a look at how to get information about available groups in Linux.

Groups in Linux are located in /etc/group file.

Quick overview:

cat /etc/group | cut -d : -f 1 | less

Notes:

  • above command will display scrollable groups as list with less program,
  • use arrow keys to scroll up and down or q key to exit list.

1. Avaialble group names example

In this section we used cat and cut commands to extract group names. cat command reads file content and cut command cuts specific data from each row. As delimiter for cut we used : (-d :) getting only first field (-f 1).

cat /etc/group | cut -d : -f 1

Part of example output:

root
daemon
bin
sys
adm
tty
disk
...

Screenshot:

Available groups in Linux displayed in Bash.
Available groups in Linux displayed in Bash.

2. Available groups with additional data example

In this section we want to show how list all group file content with cat command.

cat /etc/group

Part of example output:

root:x:0:
daemon:x:1:
bin:x:2:
sys:x:3:
adm:x:4:syslog,marcin
tty:x:5:
disk:x:6:
...

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Linux

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join