getpwuid函数是通过用户的uid查找用户的passwd数据。如果出错时,它们都返回一个空指针并设置errno的值,用户可以根据perror函数查看出错的信息。

外文名
getpwuid()
头文件
#include <sys/types.h>
原    型
struct  passwd *getpwuid
函数说明
查找用户的passwd数据

头文件

编辑

1
2
#include <sys/types.h>
#include <pwd.h>

函数原型

编辑

1
struct passwd *getpwuid(uid_t uid);

函数说明

编辑

1
2
3
4
5
6
7
8
9
10
The passwd structure is defined in <pwd.h> as follows:
struct passwd {
char *pw_name; /*user name */
char *pw_passwd; /*user password */
uid_t pw_uid; /*user id */
gid_t pw_gid; /*group id */
char *pw_gecos; /*user real name */
char *pw_dir; /*home directory */
char *pw_shell; /*shell program */
};

范例

编辑

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <pwd.h>
#include <sys/types.h>
#include <stdio.h>
intmain()
{
uid_t my_uid;
//my_uid =500;
struct passwd *my_info;
my_info =getpwuid( getuid() );
//my_info = getpwnam( "fflg" );
printf"my name = [%s]\n", my_info->pw_name );
printf"my passwd = [%s]\n", my_info->pw_passwd );
printf"my uid = [%d]\n", my_info->pw_uid );
printf"my gid = [%d]\n", my_info->pw_gid );
printf"my gecos = [%s]\n", my_info->pw_gecos );
printf"my dir = [%s]\n", my_info->pw_dir );
printf"my shell = [%s]\n", my_info->pw_shell );
return0;
}

getpwuid()的更多相关文章

  1. getpwuid()函数

    linux getpwuid 得到指定用户信息 和系统数据相关的passwd 结构 和系统数据相关的一个结构passwd定义如下 /* The passwd structure. */ struct ...

  2. getpwuid和getpwnam的用法

    如果知道一个用户的用户ID或者登录名,可以通过getpwuid或getpwnam函数获得用户的登录信息.函数原型为:         #include <pwd.h> #include & ...

  3. [APUE]系统数据文件与信息

    一.口令文件 UNIX口令文件包含下表中的各个字段,这些字段包含在 由于历史原因,口令文件是/bin/passwd,而且是一个文本文件,每一行都包括了上表中的七个字段,字段之间用":&quo ...

  4. linux服务器开发一 基础

    注:本文仅限交流使用,请务用于商业用途,否则后果自负! Linux 1.Linux介绍 Linux是类Unix计算机操作系统的统称. Linux操作系统的内核的名字也是“Linux”. Linux这个 ...

  5. 用C++实现Linux中shell的ls功能

    实现输出当前目录下的文件名 ls功能: 方法一: #include <iostream> #include <algorithm> #include <stdio.h&g ...

  6. ORA 各种oraclesql错误

    ORA-00001: 违反唯一约束条件 (.) ORA-00017: 请求会话以设置跟踪事件 ORA-00018: 超出最大会话数 ORA-00019: 超出最大会话许可数 ORA-00020: 超出 ...

  7. Linux文件管理

    虚拟文件系统(VFS)概述: VFS位于文件系统.和访问文件的系统调用(API)之间,为系统调用访问文件系统提供统一的抽象接口. 不同文件系统连接成一个单一树形结构,分别挂载(自己挂载需要用mount ...

  8. linux c/c++

    string 字符串操作 操作数的都是 ( char * )型,操作数必须是指向字符串的指针("a"),不能是字符('a'),操作时不考虑末尾的'\0'. size_t strle ...

  9. linux高级编程补充知识

    F: 计算机系统结构: ------------------------------- 应用程序 ----------------- |  库函数 -------------------------- ...

随机推荐

  1. 1-19-1 RHEL6启动原理和故障排除

    大纲: 一.RHEL6系统启动原理 BIOS--->mbr--->bootloader--->内核--->init--->/etc/rc.d/rc.sysinit---& ...

  2. How to create Oracle ASM devices using device-mapper multipath devices in Red Hat Enterprise Linux 6

    How to create Oracle ASM devices using device-mapper multipath devices in Red Hat Enterprise Linux 6 ...

  3. 007PHP基础知识——类型转换 外部变量

    <?php /**类型转换 */ /*1.自由转换*/ /*2.强制转换:不改变原变量,生成新的变量*/ //转换为字符串: /*$a=100; $b=(string)$a; var_dump( ...

  4. 【51nod-1010】因子只含有2 3 5的数

    K的因子中只包含2 3 5.满足条件的前10个数是:2,3,4,5,6,8,9,10,12,15. 所有这样的K组成了一个序列S,现在给出一个数n,求S中 >= 给定数的最小的数. 例如:n = ...

  5. 八、dbms_rls(实现精细访问控制)

    1.概述 本报只适用于Oracle Enterprise Edition,它用于实现精细访问控制,并且精细访问控制是通过在SQL语句中动态增加谓词(WHERE子句)来实现的.通过使用ORACLE的精细 ...

  6. mac下的一些mysql操作

    #一.从终端进入mysql 不同于windows下的mysql.mac下的mysql安装路径不同,所以操作上会略有不同: 以下操作以默认安装mysql为前提. ##一(1):打开终端后,先设置路径,后 ...

  7. jmeter测试FTP

    1.下载并运行FTP服务器软件:Quick Easy FTP Server V4.0.0.exe 2.点击右上角的绿色按钮,开启服务器,直到中间的红色按钮亮起 3.在账户管理处可以管理账号信息(用户名 ...

  8. flask中过滤器的使用

    过滤器 过滤器的本质就是函数.有时候我们不仅仅只是需要输出变量的值,我们还需要修改变量的显示,甚至格式化.运算等等,而在模板中是不能直接调用 Python 中的某些方法,那么这就用到了过滤器. 使用方 ...

  9. Linux下设备的基本管理

    一.系统中磁盘的管理 1.本地存储设备的识别 fdisk -l            ## 真实存在的设备(带*为启动分区) cat /proc/partition ## 系统识别的设备 blkid  ...

  10. vue 问题集合 |

    vue做类似选项卡                                                 点击改变curIndex ,  选项内容显示用 v-show="$inde ...