Bash Commands. | Ciaran Strutt

Ping Sweep

Only show responding IPs. You’ll need to sub in the rest of the CIDR to match the network you are on. .i.e. 192.168.0 vs 172.16.0 ect

.255 is excluded as we likely do not want to ping the network broadcast address.

NETWORK=192.168.0 && for IP in {1..254}; do ping -w 1 -c 1 $NETWORK.$IP | grep -q 'icmp_seq=' && echo $NETWORK.$IP; done

Count users in /etc/passwd with AWK

AWK is highly underated. You can use it to match regex patterns, split on fields, count, sum and unique.

awk -F : '! /#/ { groups[$1] += 1 } END { for (k in groups) print groups[k], k }' < /etc/passwd