Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to view the contents of Linux system / etc/passwd and / etc/shadow files

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the "Linux system / etc/passwd, / etc/shadow file content how to view" related knowledge, in the actual case operation process, many people will encounter such a dilemma, then let the editor lead you to learn how to deal with these situations! I hope you can read it carefully and be able to achieve something!

The / etc/passwd and / etc/shadow files are very important files in the Linux system, and all users' account numbers and passwords can be found in these two files.

Linuxidc@linuxidc:~/linuxidc.com$ ls-al / etc/passwd / etc/shadow-rw-r--r-- 1 root root 2469 May 17 07:12 / etc/passwd-rw-r- 1 root shadow 1303 May 17 07:12 / etc/shadow 123The above lists the access permission information for passwd and shadow files respectively, where passwd stores the account number and shadow stores the account password and other information. Let's take a look at the contents of these two files:

Introduction to the / etc/passwd file first, let's view the contents of the / etc/passwd file by using the command vim / etc/passwd:

Linuxidc@linuxidc:~/linuxidc.com$ vim / etc/passwd

We can see from the file that one row of records in / etc/passwd corresponds to a user, and each row of records is divided into seven fields by a colon (:). The format and specific meaning are as follows:

The first column is the account name

The second column is a password placeholder (x means the account requires a password to log in. If it is empty, the account can log in without a password)

The third is listed as account UID

The fourth column is GID

The fifth is to add basic information to the account, and generally store the full name of the account, contact information and other information.

The sixth is listed as the location of the account home directory.

In the seventh column, the account login Shell,/bin/bash means that the account cannot log in to the system. Shell,/sbin/nologin means that the account cannot log in to the system.

The / etc/shadow file introduction / etc/shadow file format is similar to the / etc/passwd file format, but also consists of several fields separated by ":".

Enter sudo vim / etc/shadow from the command line to view the contents of the file:

Linuxidc@linuxidc:~/linuxidc.com$ sudo vim / etc/shadow 1

Files are delimited by colons

Description:

The first column is the account name

The second column is the password (if no password is set for the account, it will be encrypted and displayed after setting the password)

The third list is the number of days since the last password was changed on January 1, 1970.

The fourth is the minimum valid days of the password. 0 means unlimited.

The fifth list is the longest valid days of the password (the default bit is 99999 days, which can be understood to never expire)

The sixth list is the number of days of grace after the password expires (after the password expires, set aside a few days for the account to change the password. At this time, it is no longer possible to log in with the old password)

The eighth is the expiration date of the account (how many days after the account expires from January 1, 1970)

The ninth column is temporarily unused.

/ etc/passwd and / etc/shadow are important files in the Linux system, so only the system administrator can modify them.

This is the end of the introduction of "how to view the contents of Linux system / etc/passwd and / etc/shadow files". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report