Introduction to/etc/passwd files in Linux __linux

Source: Internet
Author: User

1. Introduction

The passwd file is a file in a Unix-like system that records the user's password for logging in, which is usually placed under the ETC directory.

2, detailed

Define in <pwd.h>
struct passwd
{
char * PW_NAME; * * Username, POSIX.1 * *
char * PW_PASSWD; * Password * *
__uid_t Pw_uid; /* User ID, posix.1 * *
__gid_t Pw_gid; /* Group ID, posix.1 * *
char * PW_GECOS; /* Real Name or Comment field * *
char * PW_DIR; /* Home directory, POSIX.1 * *
char * Pw_shell; * * Shell Program, POSIX.1 * *
Char *pw_class;
time_t Pw_change;
time_t Pw_expire;
};
Only five of the 10 fields contained in the PASSWD structure are specified in posix.1. Most platforms support at least seven of these fields. The BSD-derived platform supports all 10 fields.

(1) Registration name (LOGIN_NAME): used to differentiate between different users. Registering names on the same system is unique. On many systems, the field is limited to a length of 8 characters (letters or numbers), and note that it is usually sensitive to letter capitalization in Linux systems. This is not the same as msdos/windows.
(2) password (passwd): The system uses the password to authenticate the user's legality. Superuser root or some advanced user can use System command passwd to change the password for all users in the system, and ordinary users can use the passwd command to change their password after logging on to the system.
Now in the Unix/linux system, the password is no longer stored directly in the passwd file, the password field in the passwd file is usually replaced by an "X", and the/etc/shadow is used as the real password file for saving data including personal passwords. Of course shadow files are not readable by ordinary users, only superuser can read them.
In addition, it should be noted that if the first character in the passwd field is "*" then it means that the account is closed and the system does not allow the user who holds the account to log in.
(3) User identification number (UID): UID is a numeric value, is the only user identity in the Linux system, used to distinguish between different users. Use the UID field when managing processes and file protection within the system. In a Linux system, the registration name and UID can be used to identify the user, but the UID is more important to the system, and for the user, the registration name is more convenient to use. For some specific purposes, there can be multiple users with different registered names but the same UID, and in fact these users with different registration names are actually the same user.
(4) Group identification Number (GID): This is the default workgroup identity for the current user. Multiple users with similar attributes can be assigned to the same group, each with its own group name and distinguished by its own group identification number. Like the UID, the user's group identification number is also stored in the passwd file. In modern Unix/linux, each user can belong to more than one group at a time. In addition to the base group where the attribution is specified in the passwd file, the user in the/etc/group file is indicated in a group.
(5) User name (USER_NAME): Contains some information about the user, such as the user's real name, office address, contact telephone, etc. In Linux systems, programs such as mail and finger use this information to identify users of the system.
(6) User home directory (home_directory): This field defines the home directory of the individual user, and when the user logs on, his shell will use the directory as the user's working directory. In the Unix/linux system, the working directory of Superuser Root is/root, while other individual users have their own working environment under the/home directory, and the system configures their own home directory for each user in the directory. The individual user's files are placed in their respective home directories.
(7) command interpreter (shell): Shell is the name of a program that runs when a user logs on to the system, usually a full pathname of a shell program.
such as/bin/bash. To prevent a particular user from logging on to the system, use/dev/null as its shell, or as an example of/sbin/nologin.
It should be noted that system administrators usually do not need to modify passwd files directly, Linux provides some account management tools to help system administrators to create and maintain user accounts.


Reference: Baidu Encyclopedia


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.