Linux 4 All

Best Linux tricks source

Posts in the RedHat category

A small and simple script to get users from a RHEL/CentOS box. It assumes that first UID is 500 and it won’t go beyond UID 999

1. Get all users

awk -F ":"  '$3>=500 && $3<1000  {print $1}' /etc/passwd

2. Get users with valid shell.

awk -F ":"  '($3>=500 && $3<1000) && ($7 ~ /sh/) {print $1,$7}' /etc/passwd

3. Get ftp users

awk -F ":"  '($3>=500 && $3<1000) && ($7 !~ /sh/) {print $1,$7}' /etc/passwd