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 !
getpwnamis used for all accesses to the passwd database. If it returns NULL, the user doesn’t exist.