Languages
[Edit]
EN

Linux - list available groups in Bash

6 points
Created by:
Greg
1505

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

 

Hey ūüĎč
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.