whoami.c源文件
2013-03-04//whoami.c
#include <unistd.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>
int
main (int argc, char **argv)
{
uid_t my_uid;
struct passwd *my_info;
my_uid = getuid ();
my_info = getpwuid (my_uid);
if (my_info)
{
printf ("My Login Name:%s\n", my_info->pw_name);
printf ("My User ID :%ld\n", my_info->pw_uid);
printf ("My Real Name:%s\n", my_info->pw_gecos);
printf ("My Home Dir :%s\n", my_info->pw_dir);
printf ("My Work Shell:%s\n", my_info->pw_shell);
}
}
//gcc -o whoami whoami.c
分类:操作系统、编程 | 标签: |