Simple question; what is the function or library that i need to use to write a very simple program (in C) (linux, ubuntu) to find out whether a user exists on the system ?
In bash i'd do :
'ls -la /home | grep $user | wc -l'
I think it's posix for C (or python) ? Can anyone help me to get started ?
An example would be perfect like :
$ doesUserExist John
0
or
$ doesUserExist John
1
Thanks !
getpwnam
is used for all accesses to the passwd database. If it returns NULL, the user doesn't exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With