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:
cat /etc/group | cut -d : -f 1 | less
Notes:
- above command will display scrollable groups as list with
lessprogram,- use arrow keys to scroll up and down or
qkey 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:
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:
...