In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "LInux how to accidentally delete / etc/passwd file problem", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "how to accidentally delete / etc/passwd file in LInux" this article.
When we are operating LInux, what should we do if we accidentally delete the / etc/passwd file?
In the Linux / etc/passwd file, each user has a corresponding record line, which records some basic attributes of that user. System administrators often come into contact with changes to this file to complete the management of users.
For example:
Root ❌ 0:0:root:/root:/bin/bash
From the above example, we can see that a 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:
1. User name: password: user identification number: group identification number: annotative description: home directory: login Shell
two。 User name (login_name): a string that represents the user's account. It is usually no more than 8 characters long and consists of uppercase and lowercase letters and / or numbers. You cannot have a colon (:) in the login name because the colon is the delimiter here. For compatibility, it is best not to include a dot character (.) in the login name and not to start with a hyphen (-) and a plus sign (+).
3. Passwd: in some systems, encrypted user passwords are stored. Although this field holds only an encrypted string of user passwords, not clear text, this is still a security concern because the / etc/passwd file is readable to all users. Therefore, many Linux systems (such as SVR4) now use shadow technology to store the real encrypted user password in the / etc/shadow file, while only one special character, such as "x" or "*", is stored in the password field of the / etc/passwd file.
4. User identification number (UID): an integer that is used internally by the system to identify the user. In general, it corresponds to the user name one by one. If several user names have the same user identification number, they will be treated as the same user internally, but they can have different passwords, different home directories, different login Shell, and so on. The value range is 0-65535. 0 is the identification number of the super user root. 1-99 is reserved by the system. As an administrative account, the identification number of the ordinary user starts from 100. In Linux systems, the limit is 500.
5. Group identification number (GID): the field records the user group to which the user belongs. It corresponds to a record in the / etc/group file.
6. Annotative description (users): the field records some personal information of the user, such as the user's real name, phone number, address, etc., and this field has no practical use. The format of this field is not uniform in different Linux systems. In many Linux systems, this field holds an arbitrary annotative description text that is used as the output of the finger command.
7. User home directory (home_directory): this 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 under 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) rights to his home directory, and other users' access to this directory is set on a case-by-case basis.
8. Login Shell (Shell): after the user logs in, he starts a process responsible for passing the user's actions to the kernel. This process is the command interpreter or a specific program, Shell, that the user runs after logging in to the system. Shell is the interface between the user and the Linux system. There are many kinds of Shell for Linux, each of which has its own characteristics. If Shell is not specified, 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 be specified as a specific program (this program is not a command interpreter). Taking advantage of this feature, we can restrict the user to run only the specified application, and when the application is finished, the user automatically exits the system. Some Linux systems require that only those programs that are registered in the system appear in this field.
So what should we do if we accidentally delete the / etc/passwd file when we are operating LInux?
one。 If the system is not rebooted after deletion, then we just need to copy the introduction file / etc/passwd- to / etc/passwd.
Cp / etc/passwd- / etc/passwd
two。 If we shut down the system after deleting the file, we will find that we can't get in when we open it.
Then let's solve it like this:
1. Press e to enter edit mode while GRUB is booting, and the ro of the linux16 line is changed to rw rd.break
2.ctrl+x execution
3. After entering single-user mode, modify the root path and copy the lead subroutine in.
Chroot / sysrootcp / etc/passwd- / etc/passwd
4. Because the security context of the copied file does not match the parent directory, we need to close selinux
Vim / etc/sysconfig/selinuxselinux = disabled
5. Twice exit exits the current root and restarts the host to return to normal
The above is all the contents of this article entitled "how to solve the problem of accidentally deleting / etc/passwd files in LInux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow 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.