Troubleshoot issues where Linux cannot use Userdel to delete users and groups

Source: Internet
Author: User

Troubleshoot issues where Linux cannot use Userdel to delete users and groups

    1. System environment
      #cat /etc/redhat-releaseCentOS release 6.7 (Final)#getenforceDisabled
    2. Problem description
      我在root账户下,删除普通账户worker时,出现如下报错信息:#userdel -r workeruserdel: user worker is currently used by process 1973 我把1973这个进程kill了,再次使用userdel -r worker命令#userdel -r workeruserdel: user worker is currently used by process 1986也就是没有真正的kill掉
    3. Cause of the problem
      There are multiple services running on the worker account, some of which may be in use by root, and we can see the PID number under the user by Ps-u Worker|awk ' {print $} '.
    4. Workaround
      (1)查看该用户的pid#ps -u worker|awk ‘{print $1}‘26778267542673526736(2)编写脚本说明:如果该用户下的pid很多,如我这次遇到了7千多个,一个一个kill是很耗费时间的,也很无聊。脚本形式如下:#ps -u worker|awk ‘{print $1}‘ > 1.txt#cat rm.sh#!/bin/bashfor i in $(cat 1.txt)do kill -9 $idoneecho "ok"执行脚本:#sh rm.sh
    5. Command VIPW
(1)#vipw –help用法:vipw [选项]选项:-g, –group 编辑 group 数据库 -h, –help 显示此帮助信息并推出 -p, –passwd 编辑 passwd 数据库 -q, –quiet 安静模式 -R, –root CHROOT_DIR chroot 到的目录 -s, –shadow 编辑 shadow 或 gshadow 数据库(2)使用vipw原因保证数据的一致性,不然可能会造成系统崩溃或者一些莫名其妙的问题。(3)具体操作#vipw找到你用户worker,用dd删除那行(记得保存:wq or :x)。。之后。#vipw -s找到用户worker所属组,用dd删除即可(记得保存:wq or :x)(4)检查worker是否还存在#grep worker /etc/passwd

Troubleshoot issues where Linux cannot use Userdel to delete users and groups

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.