#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
int main(int argc, char **argv)
{
struct passwd *pw;
if(argc <= 1) {
printf("./getpwuid \n");
return 0;
}
pw = getpwnam(argv[1]);
if( pw != NULL ) {
printf("User name %s\n",pw->pw_name);
printf("user password %s\n",pw->pw_passwd);
printf("user id %d\n",pw->pw_uid);
printf("group id %d\n",pw->pw_gid);
printf("real name %s\n",pw->pw_gecos);
printf("home directory %s\n",pw->pw_dir);
printf("shell program %s\n",pw->pw_shell);
} else {
printf("User not found!\n");
}
return 0;
}
在付费自习室元年的年末,我去体验了一下
4 years ago
0 comments:
Post a Comment