In Unix-like systems, there are two types of users: system and normal users. System users are entities created by the system to run non-interactive processes, and they usually have UIDs ranging from 0 to 999. Normal users, on the other hand, are human users created by root or another user with root privileges. They typically receive UIDs starting from 1000 onwards.
The getent passwd command in the script retrieves user account information from the system's databases. This command is preferred over reading /etc/passwd because some Unix systems might not use /etc/passwd or have users not specified there. Also, some users might be disabled and can no longer log in with their login command set to /bin/false or /usr/sbin/nologin.
The awk command in the script filters the user account information based on the UID criteria. The -F: option sets the field separator to :, and '{print $1}' instructs awk to print the first field (username) of each line that meets the condition. The condition checks if the UID is greater or equal to 1000 and less than 65344, or if the UID is 0. These ranges correspond to the typical UID ranges for normal users.
The $3 >= 1000 && $3 < 65344 || $3 == 0 is the selection criteria. Here, $3 refers to the third field in each line of input. The command checks whether this field is greater than or equal to 1000 and less than 65344, or if it equals 0.
My YouTube Channel
More shell script videos and linux tutorials on my YouTube Channel.