This one-liner will display all users with UIDs over 999 and under 2000. This includes valid users on an Ubuntu system but may be different on other machines.
┌──[jason@192.168.1.2]─[~/Documents] └──╼ ╼ $ awk -F: '{if($3>999 && $3<2000)print $1,$3,$6}' /etc/passwd jason 1000 /home/jason kirk 1001 /home/kirk |
This is a very good example of how to list multiple fields with awk.
This very complicated one-liner below will show all users in the /etc/shadow file that have actual passwords. This shows only valid users that can be used to log into the system.
┌──[jason@192.168.1.2]─[~/Documents] └──╼ ╼ $ sudo awk -F: '{if($2 != "*" && $2 != "!" && $2 != "!!") print $1,$2}' /etc/shadow | grep "$6$" root $6$GKxeRen.rYXhvr49$qb0VpZesUwfTc90HUVUXFtD.tfgnRv26qFQCahaeDShpXfy8UTYwlsvCMGPW6GPSF.nGYlTZgiFvADymCiv/T/ jason $6$wNzkQKNeYMeOZcQM$tvZYw/IDYG3BZ0RcmAZ3YYc311mSOQAdcpCWLOal7OjpBpLkfBgcOk0HSX06pKsRVw26GbaWcIFtjIQiyvfkI0 kirk $6$6Kkc/gtgE/Olz1ac$hAfyfKtknvmju.Z3l7r3lW1sS9kMPPXGJE9IYBbAh8plN4S/DN7RyxPC2/l5C0iL0fGu665jE268l0g.VB2Ui. |
The /etc/login.defs file contains the maximum and minimum values for the automatic assignment of user ID numbers on Linux.
# # Min/max values for automatic uid selection in useradd # UID_MIN 1000 UID_MAX 60000 # System accounts #SYS_UID_MIN 100 #SYS_UID_MAX 999 # # Min/max values for automatic gid selection in groupadd # GID_MIN 1000 GID_MAX 60000 # System accounts #SYS_GID_MIN 100 #SYS_GID_MAX 999 |
This enables customization of the login parameters and various options regarding passwords. This is why Linux is so good on a server, the users may be controlled to a minute level.