Linux/UNIX system data files and information

Source: Internet
Author: User
The system data files and information password files are stored in etcpasswd. you can use the following function to obtain the password file items. Include & lt; sys system data file and information password file

Stored in/etc/passwd. use the following function to obtain the password file.

# Include

# Include

Struct passwd * getpwnam (const char * name );

Struct passwd * getpwuid (uid_t uid );

If you want to view only the login name or user ID, the above two functions can meet the requirements, but some programs want to view the entire password file. The following three functions can be used for this purpose.

# Include

# Include

Struct passwd * getpwent (void );

Void setpwent (void );

Void endpwent (void );

Shadow password

Shadow password file: stores the encryption password

Use the following function to access the shadow password file:

# Include

Struct spwd * getspnam (const char * name );

Struct spwd * getspent (void );

Void setspent (void );

Void endspent (void );

Group files

The following functions are used to view the group name or value group ID.

# Include

# Include

Struct group * getgrnam (const char * name );

Struct group * getgrgid (gid_t gid );

To search the entire group of files, you can use the following three functions:

# Include

# Include

Struct group * getgrent (void );

Void setgrent (void );

Void endgrent (void );

Additional group ID

You can use the following three functions to obtain and set additional group IDs:

# Include

# Include

Int getgroups (int size, gid_t list []);

# Include

# Include

Int setgroups (size_t size, const gid_t * list );

# Include

# Include

Int initgroups (const char * user, gid_tgroup );

Time and date routines

# Include

Time_t time (time_t * t );

Returns the current time and date.

# Include

Int gettimeofday (struct timeval * TV, structtimezone * tz );

The above functions are also used to obtain the current time and date, but the resolution is higher (up to microseconds ).

# Include

Double difftime (time_t time1, time_ttime0 );

Calculate the difference between two time values and return the value of the time1-time2 as a floating point number.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.