search
HomeSystem TutorialLINUXDetailed explanation of /etc/passwd file in Linux

Detailed explanation of /etc/passwd file in Linux

Feb 12, 2024 pm 05:18 PM
linuxlinux tutoriallinux systemlinux commandshell scriptembeddedlinuxGetting started with linuxlinux learning

Did you know that in the Linux system, each user has corresponding record lines in the /etc/passwd file. These record lines contain some basic attributes of the user. As a system administrator, it is a common job to make frequent changes to this file to manage users.

Detailed explanation of /etc/passwd file in Linux

Its content is similar to the following example:

Detailed explanation of /etc/passwd file in Linux

We can see from the above example that a row of records in /etc/passwd corresponds to a user, and each row of records is separated into 7 fields by a colon (:). Its format and specific meaning are as follows:

Username: Password: User identification number: Group identification number: Commentary description: Home directory: Login Shell

"username"

A string representing the user account. Usually no more than 8 characters in length and composed of uppercase and lowercase letters and/or numbers. There cannot be a colon (:) in the login name because colon is the separator here. For the sake of compatibility, it is best not to include the dot character (.) in the login name, and do not start with a hyphen (-) and a plus sign ().

"Password"

In some systems, encrypted user passwords are stored. Although this field only stores the encrypted string of the user's password, not plain text, since the /etc/passwd file is readable by all users, this is still a security risk. Therefore, many Linux systems (such as SVR4) now use shadow technology to store the real encrypted user password in the /etc/shadow file, and only store a special password in the password field of the /etc/passwd file. Characters, such as "x" or "*".

"User Identification Number"

is an integer, which is used internally by the system to identify users. Generally, it corresponds to the username one-to-one. If the user identification numbers corresponding to several user names are the same, they will be regarded as the same user internally by the system, but they can have different passwords, different home directories, different login shells, etc. Usually the value range of user identification numbers is 0 to 65535. 0 is the identification number of the super user root, 1 to 99 are reserved by the system as management accounts, and the identification numbers of ordinary users start from 100. On Linux systems, this limit is 500.

"Group identification number"

The

field records the user group to which the user belongs. It corresponds to a record in the /etc/group file.

"Annotation Description"

The

field records some personal information of the user, such as the user's real name, phone number, address, etc. This field has no practical use. The format of this field is not uniform in different Linux systems. In many Linux systems, this field stores an arbitrary comment description text, which is used as the output of the finger command.

"Main directory"

is the user's starting working directory, which is the directory where the user is located after logging in to the system. In most systems, each user's home directory is organized in the same specific directory, and the name of the user's home directory is the user's login name.

Each user has read, write, and execute (search) permissions for his or her own home directory. The access permissions of other users to this directory are set according to specific circumstances. After the user logs in, a process is started, which is responsible for transmitting the user's operations to the kernel. This process is the command interpreter or a specific program, that is, the Shell, that is run after the user logs in to the system. The Shell is the interface between the user and the Linux system. There are many types of Linux Shells, each with different characteristics.

Commonly used ones include sh (BourneShell), csh (CShell), ksh (KornShell), tcsh (TENEX/TOPS-20typeCShell), bash (BourneAgainShell), etc.

The system administrator can designate a shell for the user based on the system conditions and user habits. If you do not specify a shell, the system uses sh as the default login shell, that is, the value of this field is /bin/sh. The user's login shell can also be designated as a specific program (this program is not a command interpreter).

Using this feature, we can restrict users to only run specified applications. After the application is finished running, the user will automatically exit the system. Some Linux systems require that only programs registered in the system can appear in this field. There is a type of user in the system called pseudousers. These users also have a record in the Linux /etc/passwd file, but cannot log in because their login shell is empty. Their existence is mainly to facilitate system management and meet the requirements of the corresponding system processes for file owners. Common pseudo-users are shown below.

Pseudo user meaning

include:

bin has executable user command files

sys owns system files

adm owns the account file

uucp UUCP usage

lplp or lpd subsystem usage

nobody NFS usage

Own Account File

There are also some standard pseudo-users, such as audit, cron, mail, usenet, etc., which also have corresponding processes and files in the Linux system. However, since the Linux /etc/passwd file is readable by all users, if the user's password is too simple or has obvious patterns, it can be easily cracked by attackers. Therefore, in Linux systems with high security requirements, the encrypted passwords are stored separately in the /etc/shadow file, and only the super user has read permission to the file, thus protecting the security of the user password. .

The above is the detailed content of Detailed explanation of /etc/passwd file in Linux. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:良许Linux教程网. If there is any infringement, please contact admin@php.cn delete
How does process management differ between Linux and Windows?How does process management differ between Linux and Windows?May 04, 2025 am 12:04 AM

The main difference between Linux and Windows in process management lies in the implementation and concept of tools and APIs. Linux is known for its flexibility and power, relying on kernel and command line tools; while Windows is known for its user-friendliness and integration, mainly managing processes through graphical interfaces and system services.

What are the typical use cases for Linux versus Windows?What are the typical use cases for Linux versus Windows?May 03, 2025 am 12:01 AM

Linuxisidealforcustomization,development,andservermanagement,whileWindowsexcelsineaseofuse,softwarecompatibility,andgaming.Linuxoffershighconfigurabilityfordevelopersandserversetups,whereasWindowsprovidesauser-friendlyinterfaceandbroadsoftwaresupport

What are the differences in user account management between Linux and Windows?What are the differences in user account management between Linux and Windows?May 02, 2025 am 12:02 AM

The main difference between Linux and Windows in user account management is the permission model and management tools. Linux uses Unix-based permissions models and command-line tools (such as useradd, usermod, userdel), while Windows uses its own security model and graphical user interface (GUI) management tools.

How does the command line environment of Linux make it more/less secure than Windows?How does the command line environment of Linux make it more/less secure than Windows?May 01, 2025 am 12:03 AM

Linux'scommandlinecanbemoresecurethanWindowsifmanagedcorrectly,butrequiresmoreuserknowledge.1)Linux'sopen-sourcenatureallowsforquicksecurityupdates.2)Misconfigurationcanleadtovulnerabilities.Windows'commandlineismorecontrolledbutlesscustomizable,with

How to Make a USB Drive Mount Automatically in LinuxHow to Make a USB Drive Mount Automatically in LinuxApr 30, 2025 am 10:04 AM

This guide explains how to automatically mount a USB drive on boot in Linux, saving you time and effort. Step 1: Identify Your USB Drive Use the lsblk command to list all block devices. Your USB drive will likely be labeled /dev/sdb1, /dev/sdc1, etc

Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Best Cross-Platform Apps for Linux, Windows, and Mac in 2025Apr 30, 2025 am 09:57 AM

Cross-platform applications have revolutionized software development, enabling seamless functionality across operating systems like Linux, Windows, and macOS. This eliminates the need to switch apps based on your device, offering consistent experien

Best Linux Tools for AI and Machine Learning in 2025Best Linux Tools for AI and Machine Learning in 2025Apr 30, 2025 am 09:44 AM

Artificial Intelligence (AI) is rapidly transforming numerous sectors, from healthcare and finance to creative fields like art and music. Linux, with its open-source nature, adaptability, and performance capabilities, has emerged as a premier platfo

5 Best Lightweight Linux Distros Without a GUI5 Best Lightweight Linux Distros Without a GUIApr 30, 2025 am 09:38 AM

Looking for a fast, minimal, and efficient Linux distribution without a graphical user interface (GUI)? Lightweight, GUI-less Linux distros are perfect for older hardware or specialized tasks like servers and embedded systems. They consume fewer res

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool