EN
Linux - list available groups in Bash
6 points
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:
xxxxxxxxxx
1
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.
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
).
xxxxxxxxxx
1
cat /etc/group | cut -d : -f 1
Part of example output:
xxxxxxxxxx
1
root
2
daemon
3
bin
4
sys
5
adm
6
tty
7
disk
8
...
Screenshot:

In this section we want to show how list all group file content with cat
command.
xxxxxxxxxx
1
cat /etc/group
Part of example output:
xxxxxxxxxx
1
root:x:0:
2
daemon:x:1:
3
bin:x:2:
4
sys:x:3:
5
adm:x:4:syslog,marcin
6
tty:x:5:
7
disk:x:6:
8
...