In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Today, I would like to share with you the relevant knowledge of what is the directory where linux stores user information. The content is detailed and the logic is clear. I believe most people still know too much about this, so share this article for your reference. I hope you can get something after reading this article. Let's take a look.
User information is stored in linux's "etc" directory. The etc directory is used to store the main configuration files of the system, such as the user's account password and other files; the passwd file in this directory is the user profile of the system, which stores the basic information of all users in the system, while the shadow file stores the password information of users in the system.
The operating environment of this tutorial: linux5.9.8 system, Dell G3 computer.
User information is stored in linux's "etc" directory.
Linux etc is used to store the main configuration files of the system, such as the user's account password files, the start files of various services, etc. Generally speaking, the attributes of the files in this directory can be checked by ordinary users, but only root has the right to modify them.
A file that stores user information in the etc directory
1. / etc/passwd file
/ etc/passwd file, which is the system user profile, stores the basic information of all users in the system, and all users can read this file.
Let's take a look at this file with the Vim command to see what it contains. Execute the command as follows:
[root@localhost ~] # vi / etc/passwd# check the contents of the file root:x:0:0:root:/root:/bin/bashbin:x:1:1:bin:/bin:/sbin/nologindaemon:x:2:2:daemon:/sbin:/sbin/nologinadm:x:3:4:adm:/var/adm:/sbin/nologin... Omit part of the output.
As you can see, the content in the / etc/passwd file is very regular, with one user per line of records.
Readers may ask why there are so many users by default in the Linux system. The vast majority of these users are necessary for the normal operation of the system or service, which are often referred to as system users or pseudo-users. System users cannot be used to log in to the system, but they cannot be deleted, because once deleted, services or programs that rely on these users cannot be executed properly, resulting in system problems.
Not only that, each line of user information is separated by ":" and is divided into seven fields, each of which has the following meaning:
User name: password: UID (user ID): GID (group ID): descriptive information: home directory: default Shell
2. / etc/shadow file
/ etc/shadow file, which is used to store the password information of users in Linux system, also known as "shadow file".
Because the / etc/passwd file allows all users to read, it can easily lead to the disclosure of the user's password, so the Linux system separates the user's password information from the / etc/passwd file and puts it in this file separately.
Only root users have read rights to the / etc/shadow file, and other users do not have any permissions, which ensures the security of the user's password.
Note that if the permissions of this file are changed, you need to pay attention to whether it is a malicious attack.
Before introducing this file, let's open it and execute the following command:
[root@localhost ~] # vim / etc/shadowroot: $6 $9w5Td6lg$bgpsy3olsq9WwWvS5Sst2W3ZiJpuCGDY.4w4MRk3ob/i85fl38RH15wzVoom ff9isV1 PzdcXmixzhnMVhMxbvO:15775:0:99999:7:::bin:*:15513:0:99999:7:::daemon:*:15513:0:99999:7:::... Omit part of the output.
Like the / etc/passwd file, each line in the file represents a user, using ":" as the delimiter, except that each line of user information is divided into nine fields. Each field has the following meaning:
User name: encrypted password: last modification time: minimum modification time interval: password validity period: warning days before password needs to be changed: grace time after password expiration: account expiration time: reserved field
3. / ect/group file
The / ect/group file is a user group profile, that is, all information about the user group is stored in this file.
This file is the file corresponding to the record group ID (GID) and the group name. As mentioned earlier, the fourth field of each line of user information in the etc/passwd file records the user's initial group ID, so what is the group name of this GID? You need to look in the / etc/group file.
The contents of the / etc/group file can be seen through Vim:
[root@localhost] # vim / etc/grouproot:x:0:bin:x:1:bin,daemondaemon:x:2:bin,daemon... Omit part of the output. Lamp:x:502:
As you can see, each line in this file represents a user group. In the previous section, we created the lamp user, and the system generates a lamp user group by default. Here you can see that the GID of this user group is 502, which is currently only the initial group for lamp users.
In each user group, the ":" is still used as the separator between the fields, which is divided into four fields. The corresponding meaning of each field is:
Group name: password: GID: list of users in this user group
4. / etc/gshadow file
/ etc/gshadow file: password information for storage group users
Let's take a look at the contents of this file with the Vim command:
[root@localhost ~] # vim / etc/gshadowroot:::bin:::bin, daemondaemon:::bin, daemon... Omit part of the output... lampVOLING:
In the file, each line represents the password information of a group of users, and each line of information is divided into four fields with ":" as a separator. The meaning of each field is as follows:
Group name: encrypted password: group administrator: group attached user list above is "what is the directory where linux stores user information?" all the contents of this article, thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.