Bite 165. Parse an /etc/passwd file output
Login and get codingThe
/etc/passwdfile is a text-based database of information about users that may log into the system or other operating system user identities that own running processes. (Wikipedia).In this Bite you complete the function
get_users_for_shellthat takes a/etc/passwdmultiline string and a shell to filter on (defaultbash). Parse the output returning alistof usernames that match the shell.So for this truncated
/etc/passwdstring:avahi:x:107:108:Avahi mDNS daemon,,,:/var/run/avahi-daemon:/bin/false postfix:x:108:112::/var/spool/postfix:/bin/false ssh-rsa:x:1004:1004::/home/ssh-rsa:/bin/bash artagnon:x:1005:1005:Ramkumar R,,,,Git GSOC:/home/artagnon:/bin/bash"""... the resulting user list would be:
['artagnon', 'ssh-rsa']Good luck and keep calm and code in Python!
Will you be the 358th person to crack this Bite?
Resolution time: ~32 min. (avg. submissions of 5-240 min.)
Our community rates this Bite 3.64 on a 1-10 difficulty scale.
» You can do it! 😌