Linux learning and problem summary

Record the problems and experiences encountered in the process of java learning and programming, and continuously update



[1. The error userdel: user xiachen is currently used by process 59257 is reported when deleting a user and its home directory]
Under the root user, the userdel -r xiachen(-r 参数表示 删除主目录和邮件池)error is reported as follows:
write picture description here
Problem analysis: The current user xiachen has a process running, and the user xiachen cannot be deleted.
Problem solving: Method ① is because there is a process running, so just kill it? So kill 59257, execute it again userdel -r xiachenand still report the same error. Check it out and use kill -9 <pid> to end the process. So execute kill -9 59257, delete successfully (the difference between kill and kill -9 can be seen in this blog post Linux kill and kill-9 difference ).
Method ② Press ctrl + D madly until you log out, then log in to root, delete it, and you're done.


[2. After adding the user usertest, switch to usertest and report an error [root@node1 home]# su xiachen bash: /home/usertest/.bashrc: insufficient permissions]

Analysis of the problem: The problem is that the permissions are not enough. The problem is that the newly added user testuser has no permissions to the files in his home directory (Explanation: /home is the root directory where all user files are stored, which is the base point of the user's home directory. For example, the home directory of the user user is /home/user)? The biggest possibility is that the testuser user has been created once before, and the corresponding testuser user home directory is not deleted when the user is deleted. As a result, the user group to which the file belongs does not correspond to the user.

You can view the user and user group to which the file belongs under the root user.

切换到root用户
进入到cd /home/xiachen目录下
使用ll -a 查看所以文件

As shown in the figure below:
write picture description here
Obviously there is a problem with the display of users and user groups. The corresponding name is not displayed, but the displayed ID, that is to say, there is no data entry for the corresponding relationship between these IDs and user and user group names. Check the two files /etc/passwad and /etc/group (the specific content of these two files means See linux: user and group files explain /etc/passwd, /etc/shadow, /etc/group, /etc/gshadow ), found that there is no user and user group with ID 1001.
Solution:
Method ①: Delete the /home/usertest directory, then delete the usertest user, and recreate the testuser user
Method ②: Change the id of usertest and the id of the group to which usertest belongs to 1001, that is, change etc/passwad and /etc respectively /group The corresponding entry.

Note: If you want to userdel abcdelete the user abc with the command, use the command useradd abcto create and add the abc user again without error. This will delete userdel -rf abcthe user.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325422573&siteId=291194637