Languages
[Edit]
EN

Linux - list available groups in Bash

6 points
Created by:
Greg
5180

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

 

Native Advertising
­čÜÇ
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - friendly IT community for everyone.

ÔŁĄ´ŞĆ­čĺ╗ ­čÖé

Join